Question: public class Grades { public Grades() { //display underlined read display(name(),letterGrade(avg(gradesArray() )) ) ; } public int amountOfStudents() { String input = JOptionPane.showInputDialog(how many students

public class Grades

{

public Grades()

{

//display underlined read

display(name(),letterGrade(avg(gradesArray() )) ) ;

}

public int amountOfStudents()

{

String input = JOptionPane.showInputDialog("how many students are in this class");

return Integer.parseInt(input);

}

public String name()

{

return JOptionPane.showInputDialog("Enter the student's name");

}

public int[] gradesArray()

{

int [] grades = new int [3];

for(int a = 0; a

{

String input = JOptionPane.showInputDialog("enter the student's grades");

grades[a] = Integer.parseInt(input);

}

return grades;

}

public double avg(int [] grades)

{

int sum = 0;

for(int a = 0; a < grades.length; a++)

{

sum += grades[a];

}

return (double)sum / 3.0;

}

public char letterGrade(double avg)

{

if(avg >= 90)

return 'A';

else if(avg >=80)

return 'B';

else if(avg >= 70)

return 'C';

else if(avg >= 60)

return 'D';

else

return 'F';

}

public void display(String name, double avg, char letterGrade, int [] array)

{

String output = "";

for(int a = 0; a < array.length; a++)

{

output += array[a];

}

JOptionPane.showMessageDialog(null, name + " Scores: " + output + " average: "+ avg + " Grade: " + letterGrade);

}

}

I can't figure out why this won't work

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!