Computer Science, asked by saksham838383838, 8 months ago

In an entrance examination, students have answered English, Maths and Science papers. Write a java program to calculate and display average marks obtained by all the students. Take number of students appeared and marks obtained in all three subjects by every student along with the name as inputs.

Answers

Answered by SHREYAKARN91
1

import java.util.Scanner;

 

public class MarksCalculator

{

   public static void main(String args[])

   {

       int markArray[] = new int[5];

       int i;

       float sum=0;

       float average, percentage;

       Scanner scan = new Scanner(System.in);

 

       System.out.print("Enter marks for 5 Subjects : ");

       for(i=0; i<5; i++){

           markArray[i] = scan.nextInt();

           sum = sum + markArray[i];

       }

 

       average = sum/5;

       percentage = (sum/500) * 100;

 

       System.out.print("Average Marks = " +average);

 

       System.out.print("\nPercentage = " +percentage+ "%");

   }

}

 

Output:

Enter marks for 5 Subjects : 91 57 83 69 74

Average Marks = 74.8

Percentage = 74.8%

That’s all about Java program to calculate average and percentage of marks.

Similar questions