Calculate percentage in java. 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.

## Percentage Calculation in Java

A percent is a ratio with 100 as the second word. The term “percent” refers to the number of pieces per hundred. The word per centum is derived from the Latin phrase per centum, which means hundred. The sign percent is used in mathematics to represent percent. A tenth of a whole is one percent. As a result, it may be expressed as both a decimal and a fraction. Simply divide a percentage by 100 to convert it to a decimal. For instance, 50% becomes 0.5, 20% becomes 0.2, and 1% becomes 0.01.

## Average in Java Program

The terms average, mean, median, and norm all refer to a position in the middle. The quotient generated by dividing the total of a collection of figures by the number of figures is known as the average. The mean may be the basic average or it may indicate a figure in the middle of two extremes if you scored an average of 85 on exams.

```
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.in);
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+ "%");
}
}
```

Output:

Enter your marks

45

67

78

13

54

67

Average= 54.0 Percentage= 54.000004%