Answer to Question #272441 in Java | JSP | JSF for dreaper

Question #272441
  1. Create a folder named LastName_FirstName on your local disk
  2. Write a program that calculates the average grade of a student. The program should perform the following:
  • Prompts the user to input five decimal numbers.
  • Compute the average grade of five entered decimal.
  • Output the average grade with two decimals places.

3. Name the class as AverageGradeCalculator and save the file.

4. Compile and execute the program using command prompt

5. correct and syntax and logical errors if there is any.


1
Expert's answer
2021-11-28T05:26:15-0500
import java.util.Scanner;

public class AverageGradeCalculator {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double averageGrade = 0;
        System.out.println("Enter five decimal numbers:");
        for (int i = 0; i < 5; i++) {
            averageGrade += in.nextDouble();
        }
        System.out.printf("Average grade: %.2f\n", averageGrade / 5);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS