Here is the problem from the book:
"Write a class that uses a string array or arraylist object to hold 5 students names, an array of 5 chars to hold 5 students letter grades, and five array of 4 doubles each to hold each students set of test scores. The class should have methods that return a specific students name, average test score, and a letter grade based on the average.
Demonstrate the class in a program that allows the user to enter each student's name and his four test scores. It should display each students average test score and letter grade."
Here is the code I have so far. A buddy and I wrote this together but we cant seem to fix the syntax errors. Any help is appreciated.
PHP Code:
public class CST150KLHW8gradeBook {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
private final int NUM_STUDENTS = 5;// Holds number of students
private final int NUM_TESTS = 4;// Holds number of tests
private String[] names = new String[NUM_STUDENTS]; //Holds students names
private char[] grades = new char[NUM_STUDENTS]; // Holds grades
private double[] scores1 = new double[NUM_TESTS];// Holds score for first test
private double[] scores2 = new double[NUM_TESTS];//Holds score for second test
private double[] scores3 = new double[NUM_TESTS];//Holds score for third test
private double[] scores4 = new double[NUM_TESTS];//Holds score for fourth test
private double[] scores5 = new double[NUM_TESTS];// Holds score for fifth test
public String getName()// Gets students names
public String getTestavg()//Gets the test average
public String getGrade()//Gets the letter grade
{
public void setName(String n)
{
name = n;
}
public String getName()
return name;
}
public void setTest(double t,int i)
{
test[i] = t;
}
public double getTest(int i)
{
return test[i];
}
public double getTestAvg(){
double sum = 0;
double avg;
for(int i = 0; i < test.length; i++)
{
sum += test[i];
}
avg = sum / test.length;
return avg;
}
public char getGrade(){
double average = getTestAvg();
char grade=0;
if(average >= 90)
grade = 'A';
else if (average >= 80)
grade = 'B';
else if (average >= 70)
grade = 'C';
else if (average >=60)
grade = 'D';
else if (average < 60)
grade = 'F';
return grade;
}