Computer Science, asked by sahiltripathi1974, 1 day ago

write a program to find average of 5 number using scanner class​

Answers

Answered by Shivu516
2

Hope it helps ^_^

import java.util.Scanner;

public class AverageCalculator{

   public static void main (String [] args) {

       //Taking input from the user

       Scanner sc = new Scanner(System.in);

       System.out.print("Enter the first number: ");

       double num1 = sc.nextDouble();

       System.out.print("Enter the second number: ");

       double num2 = sc.nextDouble();

       System.out.print("Enter the third number: ");

       double num3 = sc.nextDouble();

       System.out.print("Enter the third number: ");

       double num4 = sc.nextDouble();

       System.out.print("Enter the third number: ");

       double num5 = sc.nextDouble();

       //Main part comes here

       double Average = (num1 + num2 + num3 + num4 + num5 ) / 5;

       System.out.println("The average of the given numbers is " + Average);

   }

}

Outputs:

Enter the first number: 28

Enter the second number: 29

Enter the third number: 30

Enter the third number: 31

Enter the third number: 32

The average of the given numbers is 30.0

Please mark my answer as Brainliest if you think that it's good

I typed really fast

Similar questions