Computer Science, asked by murseethabegum2006, 7 months ago

write a java program to find the average of 10 variables​

Answers

Answered by agarwalpooja0246
1

Explanation:

import java.util.Scanner;

public class JavaExample {

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

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

double num1 = scan.nextDouble();

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

double num2 = scan.nextDouble();

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

double num3 = scan.nextDouble();

scan.close();

System.out.print("The average of entered numbers is:" + avr(num1, num2, num3) );

}

public static double avr(double a, double b, double c)

{

return (a + b + c) / 3;

}

}

Output:

Following is the screenshot of the output of above program:

Enter the first number : 12

Enter the second number : 21.5

Enter the third number : 8.5

The average of entered number is : 14.0

U can find the average of 10 variables by this method.

Similar questions