Computer Science, asked by shanmukha7321, 1 month ago

write a program to accept 3 numbers from keyboard through input stream reader class and find their sum,average and product​

Answers

Answered by anindyaadhikari13
6

\textsf{\large{\underline{Solution}:}}

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);

   }

}

\textsf{\large{\underline{Logic}:}}

  1. Accept three numbers from the user, say a, b and c.
  2. Add the numbers entered and store the result in 'sum'.
  3. Divide sum by 3 so as to calculate the average. Store the result in 'average' variable.
  4. Now multiply all the numbers entered and store the result in 'product'.
  5. Display the sum, average and product.

See the attachment for output.

Attachments:
Similar questions