Avg.java
Aim:
To find average of three numbers
Source code:
import java.lang.*;
import java.util.*;
class Avg3
{
public static void main(String args[])
{
double a,b,c,avg;
System.out.println("Enter values for a,b,c");
Scanner s1=new Scanner(System.in);
a=s1.nextDouble();
b=s1.nextDouble();
c=s1.nextDouble();
avg=(a+b+c)/3;
System.out.println("Average of three numbers="+avg);
}
}
Output:
Enter values for a,b,c
2
4
5
Average of three numbers=3.66666666666666
No comments:
Post a Comment