- Write a in java program to input marks in five subjects. Display the total marks and also the average marks with appropriate messages.
Answers
Answer:
// Java program to find Total Average and percentage of Five Subjects
import java.util.Scanner;
public class Totalof5subjects1 {
private static Scanner sc;
public static void main(String[] args)
{
int english, chemistry, computers, physics, maths;
float total, Percentage, Average;
sc = new Scanner(System.in);
System.out.print(" Please Enter the Five Subjects Marks : ");
english = sc.nextInt();
chemistry = sc.nextInt();
computers = sc.nextInt();
physics = sc.nextInt();
maths = sc.nextInt();
total = english + chemistry + computers + physics + maths;
Average = total / 5;
Percentage = (total / 500) * 100;
System.out.println(" Total Marks = " + total);
System.out.println(" Average Marks = " + Average);
System.out.println(" Marks Percentage = " + Percentage);
}
}
Explanation: