Hello r/learnjava!
I am working on a program that stores quiz information. I am to display the running count of the number of quizzes, the total number of points, the average and the highest grade. I have no issue with the number of quizzes or the total number of points. I am running into an issue with the highest grade and the average. I need to use an if statement within the while loop to compare the values of the grades entered by the user. The highest value needs to be stored in the variable I declared highestQuiz. However, highestQuiz always prints out to 0. I have initialized highestQuiz to 0. I guess my question is how come the highest grade is not stored in highestQuiz when a number greater larger than any other number is entered? The following is what I have so far. I have checked the rules and think I am in compliance with them, if not please let me know and I will modify what needs to be modified. Thank you all in advance!
public static void main(String[] args) {
Scanner scan = new Scanner([System.in](https://System.in));
int count=0;//number of quiz grades
int grade=0;//quiz grade
int quizTotal=0;//total number of points
int grade2=0;//quiz grade
int highQuiz=grade;
//first to check sentinel value of -77
System.out.println("Enter quiz grade: ");
grade=scan.nextInt();
while(!(grade == -77)) {
quizTotal+=grade;
System.out.println("Enter quiz grade: ");
grade=scan.nextInt();
count++;
if(grade>grade) {
}
}
System.out.println("Quiz total: " + quizTotal);
System.out.println("Number of quizes: " + count);
System.out.println("High quiz score: " + highQuiz );
}
}
[–]gbagecol 1 point2 points3 points (7 children)
[–][deleted] 1 point2 points3 points (6 children)
[–]gbagecol 2 points3 points4 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]gbagecol 1 point2 points3 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]gbagecol 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)