Answer to Question #238368 in Java | JSP | JSF for java

Question #238368

Write a program called GradeBook.java. This program should do the following:

1. Prompt the user to enter 3 grades one at a time, and read them in using Scanner (assume the grades are integer numbers).

2. Compute the average of the 3 grades.

3. Print the resulting average (do not worry about rounding the result, just print the value with all of the decimal places).

Here is an example of what the program output will look like (bold-italics indicate user input):

Enter grade 1: 89

Enter grade 2: 93

Enter grade 3: 72

84.666666667 



1
Expert's answer
2021-09-17T02:04:15-0400


import java.util.Scanner;


public class GradeBook {


	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);
		int grade1, grade2, grade3;
		System.out.print("Enter grade 1: ");
		grade1 = keyboard.nextInt();
		System.out.print("Enter grade 2: ");
		grade2 = keyboard.nextInt();
		System.out.print("Enter grade 3: ");
		grade3 = keyboard.nextInt();
		double average=(double) ((grade1+grade2+grade3)/3.0);
		System.out.println(average);
		keyboard.close();
	}
}

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