# Java Program to Calculate Average and Percentage Marks

## Calculate Average and Percentage Marks

To calculate average and percentage marks of a students, you have to ask to the user to enter marks obtained in some subjects (say 5). Place summation of 5 subject's marks in a variable say sum and place sum/5 in a variable say avg then place sum/500*100 in a variable say perc, then display the result on the output screen.

## Java Programming Code to Calculate Average and Percentage Marks

Following Java Program ask to the user to enter the marks obtained in 5 subjects to calculate and display the average and percentage marks :

```/* Java Program Example - Calculate Average and Percentage */

import java.util.Scanner;

public class JavaProgram
{
public static void main(String args[])
{
int mark[] = new int[5];
int i;
float sum=0;
float avg, perc;
Scanner scan = new Scanner(System.in);

System.out.print("Enter marks Obtained in 5 Subjects : ");
for(i=0; i<5; i++)
{
mark[i] = scan.nextInt();
sum = sum + mark[i];
}

avg = sum/5;
perc = (sum/500) * 100;

System.out.print("Average Marks = " +avg);

System.out.print("\nPercentage = " +perc+ "%");
}
}```

When the above Java Program is compile and executed, it will produce the following output:

### Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

Tools
Calculator