Sum And Percentage Of Five Subjects In Java
This Java program allows users to enter five different values for five subjects. And then, this Java program finds the Total, Average, and Percentage of those Five Subjects. In this example, we are using the Arithmetic Operators to perform arithmetic operations.
package ex1;
import java.util.*;
public class avg1 {
public static void main(String[] args) {
float s1,s2,s3,s4,s5,sum,per;
System.out.print("enter a number subject marks");
Scanner kb = new Scanner(System.in);
s1 = kb.nextFloat();
s2 = kb.nextFloat();
s3 = kb.nextFloat();
s4 = kb.nextFloat();
s5 = kb.nextFloat();
sum = s1+s2+s3+s4+s5;
per = (sum/5);
System.out.print("\n sum " +sum + "\t percentage are\t" +per);
}
}
No comments:
Post a Comment