57.6k views
1 vote
Java programming

Write an application (GradeAve) that takes in from the teacher the grades for students and comes up with a class average. using the jOptionPane clas , have the teacher input (using a window) each grade as an integer. The program should allow the teacher to enter up to ten grades (there are only ten students in the class), but there also may be less than ten. Have the teacher enter a sentinel value when he/she is done entering grades (if it is below 10). Use a do loop for this problem. After the grades have been entered, display the class average. The average should be precise to two decimal places. [Note: test this to make sure it works right!!! Don’t just enter random grades, enter grades where you KNOW what the average should be—and make sure you get that average.]

User Gerdtf
by
8.1k points

1 Answer

7 votes

Final answer:

To create an application that calculates the class average for student grades using the JOptionPane class in Java programming, use a do-while loop to allow the teacher to enter up to ten grades using a window. Calculate a running total of the grades and keep track of the number of grades entered. Finally, calculate the class average and display it using JOptionPane.

Step-by-step explanation:

To create an application that calculates the class average for student grades using the JOptionPane class in Java programming, you can follow these steps:

  1. Use a do-while loop to allow the teacher to enter up to ten grades using a window.
  2. For each grade entered, store it in a variable and calculate a running total of all the grades.
  3. Keep track of the number of grades entered by incrementing a counter variable with each iteration.
  4. Allow the teacher to enter a sentinel value below 10 to indicate they are done entering grades.
  5. After the loop ends, calculate the class average by dividing the total grades by the number of grades entered.
  6. Use JOptionPane to display the class average, formatting it to two decimal places.
User Ujeenator
by
7.7k points