Showing posts with label JAVA Program to calculate percentage marks of the student. Show all posts
Showing posts with label JAVA Program to calculate percentage marks of the student. Show all posts

JAVA Program to calculate percentage marks of the student

/*
2. Write a program that calculate percentage marks of the student if marks of 6 subjects are given.
*/

import java.util.Scanner;

class Percent_pract2_2{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int sum = 0;
float avg;
int marks[] = new int[5];
System.out.println("Enter Marks of subject 1");
marks[0]=sc.nextInt();
System.out.println("Enter Marks of subject 2");
marks[1]=sc.nextInt();
System.out.println("Enter Marks of subject 3");
marks[2]=sc.nextInt();
System.out.println("Enter Marks of subject 4");
marks[3]=sc.nextInt();
System.out.println("Enter Marks of subject 5");
marks[4]=sc.nextInt();


for(int i=0;i<marks.length;i++){
sum += marks[i];
}
avg = (float)sum/marks.length;
System.out.println("Sum = "+sum);
System.out.println("percentage = "+avg);
}

}