Question: 1.1 The following codes read four grades from the user and display pass or fail based on the grade >= 60. Write a java program
1.1 The following codes read four grades from the user and display pass or fail based on the grade >= 60. Write a java program (call it WhileLoopsGrading.java) to replace the following codes with an unspecified number of grade entries. The loop terminates when the user enters a negative value. If the user enters a negative value for the first grade, the program displays the done entering grade message
// The codes for imports, class header, and the public static void main(.){ method are not // shown here.
Scanner in = new Scanner(System.in);
int grade;
int i = 0;
while (i < 4) {
System.out.print("Enter a grade: ");
grade = in.nextInt();
if (grade >= 60)
System.out.println(" Pass");
else
System.out.println(" Fail");
i++;
}
/* The above code displays the following:
Enter a grade: 99
Pass
Enter a grade: 10
Fail
Enter a grade: 88
Pass
Enter a grade: 59
Fail
done entering grades
// your new code in WhileLoopsGrading.java displays the following:
Enter a grade ( < 0 to end )
99
Pass
Enter a grade (<0 to end ):
10
Fail
Enter a grade (<0 to end ):
88
Pass
Enter a grade (<0 to end ):
59
Fail
Enter a grade (<0 to end ):
-1
done entering grades
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
