Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The file Grades.java contains a program that reads in a sequence of student grad

ID: 3621305 • Letter: T

Question

The file Grades.java contains a program that reads in a sequence of student grades and computes the average grade, the number of students who pass (a grade of at least 60) and the number who fail. The program uses a loop (which you learn about in the next section.)
1. Compile and run the program to see how it works.
2. Study the code and do the following:
-Replace the statement that finds the sum of the grades with one thats uses the += operator.
-Replace each of three statements that increment a counting variable with statements using the increment operator.
3. Run your program to make sure it works.
4. Now replace the "if" statement that updates the pass and fail counters with the conditional operator.

Explanation / Answer

Dear.. import java.util.Scanner; public class Grades { public static void main (String[] args) { Scanner reader = new Scanner(System.in); double grade; // a student's grade double sumOfGrades; // a running total of the student grades int numStudents; // a count of the students int numPass; // a count of the number who pass int numFail; // a count of the number who fail System.out.println (" Grade Processing Program "); // Initialize summing and counting variables sumOfGrades = 0; numStudents = 0; numPass = 0; numFail = 0; // Read in the first grade System.out.print ("Enter the first student's grade: "); grade = reader.nextDouble(); while (grade >= 0) { sumOfGrades += grade; int z= grade 0) { System.out.println (" Grade Summary: "); System.out.println ("Class Average: " + sumOfGrades/numStudents); System.out.println ("Number of Passing Grades: " + numPass); System.out.println ("Number of Failing Grades: " + numFail); } else System.out.println ("No grades processed."); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote