Practical 2: Write a program that calculate percentage marks of the student if marks of 6 subjects are given.
Program:
import java.util.Scanner;
public class practical2
{
public static void main(String[] args)
{
int marks[] = new int[7];
int total = 0;
float percentage = 0;
System.out.println("Please Enter 6 subject Marks : ");
Scanner scan = new Scanner(System.in);
for (int i = 1; i <= 6; i++)
{
marks[i] = scan.nextInt();
}
for (int i = 1; i <= 6; i++) {
total = total + marks[i];
}
percentage = (total * 100) / 600;
System.out.println("Students percentage = " + percentage);
}
}
Output:
Comments
Post a Comment