Hi, I'm a student of Java, and my first homework assignment is more advanced than our reading. So...I'm lost.
This question is:
Q5: Write a program that reads a list of exam scores from the keyboard. Using A=90 to 100, B=80 to 89, C=70 to 79, D=60 to 69 and F=0-59 compute: (i)The total number of students, (ii) the numbers for various grades, (iii) the percentage of total number of students for each letter grade, (iv) the range of scores for each letter grade and (v) the average score for each grade as well as for (vi) the entire class. Use a sentinel value of -1 to stop input of marks, which is not to be used in your calculations.[20]
I think I could do this with one number or an array that I could determine, but I can't figure out how to do this with an unknown array provided by the user. I KNOW my code thus far is wrong, and that's why I'd like some pointers. (It's currently a hodgepodge of things I saw that I thought might apply.)
import java.util.*;
import java.util.Scanner;
public class Grades /* This program breaks numerical grades into letter grades, computes the number of students,
the number of students per letter grade, the range of scores for each letter grade, the
average score per grade and the class average. */
{
public static void main(String[] Args)
{
System.out.println("Enter exam scores, followed by -1 when you are done entering scores.");
Scanner keyboard = new Scanner(System.in);
int []allGrades = keyboard.nextLine( );
System.out.println ("You entered the grades for " + allGrades.length + " students.")
int [] allGrades = new int;
boolean numbersLeft = true
while (numbersLeft)
{
next = keyboard.nextInt( );
if (next = < 0)
numbersLeft = false;
for int i = 0; i < allGrades.length; i++; {
if (allGrades[i] >= 90)
letterGrade = 'A';
else if (allGrades[i] >= 80)
letterGrade = 'B';
else if (allGrades[i] >= 70)
letterGrade = 'C';
else if (allGrades[i] >= 60)
letterGrade = 'D';
else letterGrade = 'F';
}
}
I know I've barely scratched the surface, but it's already off and I'd like to get on track before I tackle the other parts of the question, declare letterGrade, etc. Any pointers would be greatly appreciated. Thanks!