Beta Coder

Learn code like Beta Coder.

Breaking

Monday, September 14, 2020

Java Program to Calculate Average of Five Subjects

CALCULATE AVERAGE OF FIVE SUBJECTS

CALCULATE AVERAGE OF FIVE SUBJECTSD
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%

No comments:

Post a Comment