# Java Program to Calculate Average and Percentage Marks

• Java program to find the Total, average and percentage marks of all subjects.

In this java program, We will first take the number of subjects as input and store it in "count" variable. Then we ask user to enter the marks of all subjects using for loop. To get the total marks obtained by student we add the marks of all subject and to calculate average marks and percentage we will use following expression:

Average Marks = Marks_Obtained/Number_Of_Subjects
Percentage of Marks = (Marks_Obtained/Total_Marks) X 100

Finally, we print Total marks, Average Marks and Percentage on screen.

## Java program to find total, average and percentage marks all subjects

```package com.tcc.java.programs;

import java.util.Scanner;

/**
* Java Program to find average and percentage marks of N subjects
*/
public class AverageMarks {
public static void main(String[] args) {
int count, i;
float totalMarks = 0, percentage, average;
Scanner scanner;
scanner = new Scanner(System.in);

System.out.println("Enter number of Subject");
count = scanner.nextInt();

System.out.println("Enter Marks of " + count + " Subject");
for (i = 0; i < count; i++) {
totalMarks += scanner.nextInt();
}

average = totalMarks / count;
// Each subject is of 100 Marks
percentage = (totalMarks / (count * 100)) * 100;

System.out.println("Total Marks : " + totalMarks);
System.out.println("Average Marks : " + average);
System.out.println("Percentage : " + percentage);
}
}
```
Output
```Enter number of Subject
5
Enter Marks of 5 Subject
75 86 92 46 60
Total Marks : 359.0
Average Marks : 71.8
Percentage : 71.8
```