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.
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);
}
}
Comments
Leave a comment