Simplecode

mail@pastecode.io avatar
unknown
plain_text
10 days ago
747 B
1
Indexable
Never
import java.util.Scanner;

public class AverageCalculator {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter grades for 8 subjects: ");
        double grade1 = input.nextDouble();
        double grade2 = input.nextDouble();
        double grade3 = input.nextDouble();
        double grade4 = input.nextDouble();
        double grade5 = input.nextDouble();
        double grade6 = input.nextDouble();
        double grade7 = input.nextDouble();
        double grade8 = input.nextDouble();
        
        double average = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8) / 8;
        System.out.println("Your average grade is: " + average);
    }
}
Leave a Comment