Computer Science, asked by Anonymous, 1 year ago

java programing
find the average of any three numbers

Answers

Answered by devyani3
5
class avg
{
public static void main(int a, int b, int c)
{
int sum =0 ;
sum =a+b+c;
double avg=sum/3;
System.out.println("average of 3 no. ="+ avg) ;
}
}

Anonymous: But i think we cld use avg=(a+b+c)/3
devyani3: yeah so in the program sum already stores the value of a+b+c.
devyani3: yeah so in the program sum already stores the value of a+b+c.
devyani3: yeah so in the program sum already stores the value of a+b+c
devyani3: yeah so in the program sum already stores the value of a+b+c.
devyani3: yeah so in the program sum already stores the value of a+b+c
devyani3: yeah so in the program sum already stores the value of a+b+c.
devyani3: yeah so in the program sum already stores the value of a+b+c
devyani3: yeah so in the program sum already stores the value of a+b+c. so there's no need for that extra thing
devyani3: yeah so in the program sum already stores the value of a+b+c
Answered by mithulpranav24826
1

Answer:

import java.io.*;

public class average

{

   public static void main(String[] args) throws IOException

   {

       InputStreamReader isr=new InputStreamReader(System.in);

       BufferedReader abc= new BufferedReader(isr);

       System.out.println("Enter the First Number");

       int a=Integer.parseInt(abc.readLine());

       System.out.println("Enter the Second Number");

       int b=Integer.parseInt(abc.readLine());

       System.out.println("Enter the Third Number");

       int c=Integer.parseInt(abc.readLine());

       double avg=(a+b+c)/3;

       System.out.println("The average is= "+avg);

   }

}

Answerd by M.Mithul Pranav

Hope it helps

Similar questions