T
TechGurl
I am trying to write a program that will total the number of grades
entered and also give me a total of all the A's B' C's etc. Thanks
Error that I am getting:
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
numberOfA cannot be resolved //how I am to resolve this and the
others
numberOfB cannot be resolved
numberOfC cannot be resolved
numberOfD cannot be resolved
numberOfF cannot be resolved
at ExamScorer.main(ExamScorer.java:22)
public class ExamScorer
{
public static void main(String[] args)
{
System.out.println("Enter exam score: ");
int score;
char grade;
int sum;
int next;
String answer;
int countGrade = 0;
int countScore = 0;
Scanner keyboard = new Scanner(System.in);
{
System.out.println();
System.out.println("Enter all of the exam scores.");
sum=0;
int NumberOfA = 0;
int NumberOfB = 0;
int NumberOfC = 0;
int NumberOfD = 0;
int NumberOfF = 0;
next = keyboard.nextInt();
score = keyboard.nextInt();
grade = keyboard.next();
}
sum = sum + next;
numberOfA++;
numberOfB++;
numberOfC++;
numberOfD++;
numberOfF++;
next = keyboard.nextInt();
if (score >= 90)
grade = 'A';
else if (score >= 80)
grade = 'B';
else if (score >= 70)
grade = 'C';
else if (score >= 60)
grade = 'D';
else
grade = 'F';
System.out.println("Score = " + score);
countScore++;
System.out.println("Grade = " + grade);
countGrade++;
}
}
entered and also give me a total of all the A's B' C's etc. Thanks
Error that I am getting:
Exception in thread "main" java.lang.Error: Unresolved compilation
problems:
numberOfA cannot be resolved //how I am to resolve this and the
others
numberOfB cannot be resolved
numberOfC cannot be resolved
numberOfD cannot be resolved
numberOfF cannot be resolved
at ExamScorer.main(ExamScorer.java:22)
public class ExamScorer
{
public static void main(String[] args)
{
System.out.println("Enter exam score: ");
int score;
char grade;
int sum;
int next;
String answer;
int countGrade = 0;
int countScore = 0;
Scanner keyboard = new Scanner(System.in);
{
System.out.println();
System.out.println("Enter all of the exam scores.");
sum=0;
int NumberOfA = 0;
int NumberOfB = 0;
int NumberOfC = 0;
int NumberOfD = 0;
int NumberOfF = 0;
next = keyboard.nextInt();
score = keyboard.nextInt();
grade = keyboard.next();
}
sum = sum + next;
numberOfA++;
numberOfB++;
numberOfC++;
numberOfD++;
numberOfF++;
next = keyboard.nextInt();
if (score >= 90)
grade = 'A';
else if (score >= 80)
grade = 'B';
else if (score >= 70)
grade = 'C';
else if (score >= 60)
grade = 'D';
else
grade = 'F';
System.out.println("Score = " + score);
countScore++;
System.out.println("Grade = " + grade);
countGrade++;
}
}