java programing
find the average of any three numbers
Answers
Answered by
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) ;
}
}
{
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
Answered by
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
Math,
8 months ago
Math,
8 months ago
Math,
1 year ago
English,
1 year ago
Computer Science,
1 year ago