Write a program which prompts the user to enter the number of subjects. Now read the marks of all the subjects from the user using scanner class. Write a method which calculates the percentage of the user
Answers
Answered by
0
Answer:
import java.util.*;
class subject
{
public static void main()
{
Scanner in = new Scanner(System.in);
System.out.println("Entre the number of subjects");
int k=in.nextInt();
int s=0;
for(int i=1;i<=k;i++)
{
System.out.println("Enter the marks");
int t=in.nextInt();
s=s+t;
}
System.out.println("Your percentage is" + (s/k));
}
}
Similar questions