Computer Science, asked by markmasih9339, 18 hours ago

write a program in java to calculate the average of three subjects and display total and average marks​

Answers

Answered by samarthkrv
0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.println("Enter marks of all 3 subjects:");

 double total = 0;

     for(int i = 0; i < 3; i++){

         double x = sc.nextDouble();

         total = total + x;

     }

    double average = total/3d;

    System.out.println("The total marks in all 3 subjects is " + total);

    System.out.println("The average of all 3 subjects is " + average);

}

}

Explanation:

Similar questions