Share your repls and programming experiences

← Back to all posts
Java program to calculate percentage and average
RaghunathThilag (1)

Java program to calculate percentage and average. The Java program Percentage and Average can assist beginners in understanding the mathematics concept and how it works in the java programming language. A percentage is a number or ratio expressed as a fraction of 100 in mathematics (from Latin per centum “by a hundred”). The mode, or median, is a number that expresses the central or typical value in a collection of data.

import java.util.Scanner;
public class Main
public static void main(String args[])
int mark[] = new int[6];
int i;
float sum=0;
float average, percentage;
Scanner scan = new Scanner(;
System.out.print("Enter your marks ");
for(i=0; i<6; i++)
mark[i] = scan.nextInt();
sum = sum + mark[i];
average = sum/6;
percentage = (sum/600) * 100;
System.out.print("Average= " +average);
System.out.print("\npercentage= " +percentage+ "%");

Enter your marks 45 67
Average= 54.0
Percentage= 54.000004%