So I have to make a java program that lets you enter test scores and then displays the test scores back to you showing the number of A's, B's' C's, 'D's F's entered based on the numbers put into the program. The program is supposed to end when you enter a negative number and the negative number is not used actually in the program so the program if you entered 70 80 90 and 100 -2 it would display something like this based on the input provided
Number of A's = 2
Number of B's = 1
Number of C's = 1
Number of D's = 0
Number of F's = 0
My code is as below I have redone this program so many times it is baffling me... I really would like any kind of help possible I hope I explained this correctly, >_<...
import java.util.Scanner;
public class GradeReader {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int input;
System.out.println("Input grades scores, -1 to exit");
String garbage;
int A = 0;
int B = 0;
int C = 0;
int D = 0;
int F = 0;
while (!sc.hasNextInt()) {
System.out.println("Input numbers only 0 ... 100, -1 to exit you can enter up to 6 numbers");
int number = sc.nextInt();
System.out.println("Enter another score");
int number1 = sc.nextInt();
System.out.println("Enter another score");
int number2 = sc.nextInt();
System.out.println("Enter another score");
int number3 = sc.nextInt();
System.out.println("Enter another score");
int number4 = sc.nextInt();
System.out.println("Enter another score");
int number5 = sc.nextInt();
if (number >= 90)
{
A=A+1;
A++;
}
if (number >= 80)
{
B=B+1;
B++;
}
if (number >= 70)
{
C=C+1;
C++;
}
if (number >= 60)
{
D=D+1;
D++;
}
if (number >= 0)
{
F=F+1;
F++;
}
}
input = sc.nextInt();
while (input != -1);
{
System.out.println("Number of A's " + A);
System.out.println("Number of B's " + B);
System.out.println("Number of C's " + C);
System.out.println("Number of D's " + D);
System.out.println("Number of F's " + F);
}
}
}