write a program to input three numbers and find the sum, product, and average of these numbers
Answers
Answer:
please tell the platform in which we have to write the program
This program is in Java.
import java.util.*;
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();
//Main part comes here
double Average = (num1 + num2 + num3) / 3;
double sum = num1 + num2 + num3;
double pro = num1 * num2 * num3;
System.out.println("The sum of the given numbers is " + sum);
System.out.println("The product of the given numbers is " + pro);
System.out.println("The average of the given numbers is " + Average);
}
}
Output:
Enter the first number: 30
Enter the second number: 31
Enter the third number: 28
The sum of the following numbers is 89.0
The product of the given numbers is 26040
The average of the given numbers is 29.666666666666668