CALCULATE AVERAGE OF FIVE SUBJECTS
In this program we learn how to calculate average of five subjects by provided user using Java.Java program to calculate average of five subjects
// CALCULATE AVERAGE OF FIVE SUBJECTS
import java.util.Scanner;
class Average
{
public static void main(String []arg)
{
int s1,s2,s3,s4,s5;
float avg;
Scanner in= new Scanner(System.in);
System.out.println("\n Enter five subjects marks : ");
s1=in.nextInt();
s2=in.nextInt();
s3=in.nextInt();
s4=in.nextInt();
s5=in.nextInt();
avg=(s1+s2+s3+s4+s5)/5;
System.out.println(" \n The average = "+avg+"%");
}
}
OUTPUT:
Enter five subjects marks : 51 60 75 64 80
The average = 66.00%
The average = 66.00%
No comments:
Post a Comment