JAVA PROGRAM || Write a JAVA program to enter marks of five subjects and calculate total, average and percentage.
JAVA PROGRAM
Write a Java program to enter marks of five subjects and calculate total, average and percentage.
(Hint)
Total = s1+s2+s3+s4+s5
Average = total/5
percentage = (total/500)*100
Static :-
class TAP
{
public static void main(String args[])
{
double english=50.0,Maths=65.5,SocialScience=72.5,Science=49.0,Computer=48.5,total,average,percentage;
total=english+Maths+SocialScience + Science + Computer;
average = total/5;
percentage = (total/500)*100;
System.out.println("The total marks is :-"+total);
System.out.println("The average is :-"+average);
System.out.println("The percentage is :-"+percentage);
}
}
Output :-
Dynamic :-
import java.util.*;
class TAP
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter English Mark :-");
double english = in.nextDouble();
System.out.println("Enter Maths Mark :-");
double Maths = in.nextDouble();
System.out.println("Enter Social Science Mark :-");
double SocialScience = in.nextDouble();
System.out.println("Enter Science Mark :-");
double Science = in.nextDouble();
System.out.println("Enter Computer Mark :-");
double Computer = in.nextDouble();
double total=english+Maths+SocialScience + Science + Computer;
double average = total/5;
double percentage = (total/500)*100;
System.out.println("The total marks is :-"+total);
System.out.println("The average is :-"+average);
System.out.println("The percentage is :-"+percentage);
}
}
Output :-