CODE:
import java.util.Scanner;
public class percentage
{
public static void main(String args[])
{
int mark[] = new int[6];
int i;
float sum=0;
float avg, perc;
Scanner scan = new Scanner(System.in);
System.out.print("Enter marks Obtained in 6 Subjects");
for(i=0; i<6; i++)
{
System.out.print("\nSubjects "+ (i+1) +" : ");
mark[i] = scan.nextInt();
sum = sum + mark[i];
}
avg = sum/6;
perc = (sum/600) * 100;
System.out.println("\nTotal Marks(600) = " +sum);
System.out.println("\nPercentage = " +perc+ "%");
}
}
OUTPUT:
No comments:
Post a Comment