write a program to accept 3 numbers from keyboard through input stream reader class and find their sum,average and product
Answers
The given problem is solved using language - Java.
import java.io.*;
public class Brainly{
public static void main(String s[]) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
double a,b,c,sum,product,average;
System.out.print("Enter a number: ");
a=Double.parseDouble(br.readLine());
System.out.print("Enter a number: ");
b=Double.parseDouble(br.readLine());
System.out.print("Enter a number: ");
c=Double.parseDouble(br.readLine());
sum=a+b+c;
average=sum/3.0;
product=a*b*c;
System.out.println("Sum: "+sum);
System.out.println("Average: "+average);
System.out.println("Product: "+product);
}
}
- Accept three numbers from the user, say a, b and c.
- Add the numbers entered and store the result in 'sum'.
- Divide sum by 3 so as to calculate the average. Store the result in 'average' variable.
- Now multiply all the numbers entered and store the result in 'product'.
- Display the sum, average and product.
See the attachment for output.