Professional Documents
Culture Documents
Calculate Average and Percentage Marks in Java
Calculate Average and Percentage Marks in Java
To calculate average and percentage marks of a student in Java programming, 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.
Following Java Program ask to the user to enter the marks obtained in 5 subjects to
calculate and display the average and percentage marks :
import java.util.Scanner;
avg = sum/5;
perc = (sum/500) * 100;
When the above Java Program is compile and executed, it will produce the following output: