java program to calculate average of 3 numbers

Solutions on MaxInterview for java program to calculate average of 3 numbers by the best coders in the world

showing results for - "java program to calculate average of 3 numbers"
Bryan
14 Nov 2016
1// Java program to calculate average of 3 numbers
2import java.util.Scanner;
3public class AverageNumberDemo 
4{
5   public static void main(String[] args) 
6   {
7      Scanner sc = new Scanner(System.in);
8      System.out.print("Please enter first number: ");
9      double number1 = sc.nextDouble();
10      System.out.print("Please enter second number: ");
11      double number2 = sc.nextDouble();
12      System.out.print("Please enter third number: ");
13      double number3 = sc.nextDouble();
14      System.out.print("The average of 3 numbers is: " + calculateAverage(number1, number2, number3));
15      sc.close();
16   }
17   public static double calculateAverage(double num1, double num2, double num3)
18   {
19      return (num1 + num2 + num3) / 3;
20   }
21}
Beatrice
25 Feb 2016
1int a, b, c, d;
2		a = 2;
3		b = 3;
4		c = 5;
5		d = 10;
6		System.out.println("Average of n nubers is: " + (a + b + c + d) / 4);
7		// OR
8		Scanner scanner = new Scanner(System.in);
9		System.out.println("Enter 1st number: ");
10		int firstNumber = scanner.nextInt();
11		System.out.println("Enter 2nd number: ");
12		int secondNumber = scanner.nextInt();
13		System.out.println("Enter 3rd number: ");
14		int thirdNumber = scanner.nextInt();
15		System.out.println("Enter 4th number: ");
16		int fourthNumber = scanner.nextInt();
17		System.out.println("Enter 5th number: ");
18		int fifthNumber = scanner.nextInt();
19		System.out.println("Enter 6th number: ");
20		int sixthNumber = scanner.nextInt();
21		System.out.println("Enter Nth number: ");
22		int nthNumber = scanner.nextInt();
23		scanner.close();
24		System.out.println("Average of abouve input numbers is: "
25				+ (firstNumber + secondNumber + thirdNumber + fourthNumber + fifthNumber + sixthNumber + nthNumber)
26						/ 7.0);
queries leading to this page
write a program to find average of first p multiples of an integer n in javaprogram to find average of numbers in javajava program to calculate average of n numbersjava calculate averagewrite a program to find the average of the first p multiples of an integer n in javaaverage of two number javajava loop finding the average of 15 numbershow to find maximum average between 3 numbers in javajava program to find average of 3 numberswrite a program to find average of first p multiples of an integer n javaaverage of numbers javahow to get average of 3 numbers in java without returncalculate average of 3 numbers in java using bedmsaverage of 2 numbers in javaalgorithm to calculate average of n numbersjava program to find average of 5 numbersjava program to calculate average of sum n numbersaverage of two numbers in javaprogram to calculate the average of n numbershow to get the average of two numbers in javacalculate average of three numbers in javasum and average of n numbers in javacalculate average of n numbers in javafindaverage in java exmapleallintitle 3ajava program to find average of n numbershow to get the average of numbers javawrite a program to find average of first p multiples of an integer in javahow to get average of 3 numbers in javado while finding average of 4 numbers javaaverage of 5 numbers in javajava program to find average of 3 numberjava how to get an average of 5 numbersaverage of 3 numbers in javaaverage of three numbers in javajava average of two numbersaverage of n numbers in javafind average in java for two numbersaverage of 3 numbers javajava program to find the average of multiple numbersaverage of values 3d 3 javaaverage of numbers in java functioncalculate average of 3 numbers in javaallintitle 3ajava program to calculate average of 3 numbersjava program to calculate average of 2 numbersaverage of number using javawrite a program to compute average of n numbers in c flowchartcalculate average of ints in javaaverage of n number using function in javajava program to find the average of n numberswap to calculate average of three numbers in javajava program for average of three numbersjava program to calculate average of 3 numbersjava program to find average of n numbersaverage of 2 and 1 in javacalculate average of 3 numbers in java using bedmasjava program to calculate average of 3 numbers