Q:

Java Program For Calculate Percentage of 5 Subjects

0

Problem:- java program for student mark list using an array or simple java program for student details or java program for student mark sheet or java program for student mark list using inheritance or java program calculate student grades or java program for student mark sheet or calculate percentage in java example simple java program for student details or java program calculate student grades or student mark list program in java or mark sheet generation project in java with source code or java program for student mark list using inheritance or java program to find the grade of a student using if else or Java Program For Calculate Total Marks Of 5 Subjects And percentage.

 
Logic:- First we will ask the user for the total number of the subject after that we will enter marks of all those subjects. Now we will calculate a percentage of marks and print student marks, percentage, and Grade of Student. Percentage formula is given Below. 

Percentage of Marks = (all subject marks sum) / Total Subject *100.

Explanation:- For this problem, I am taking 5 subjects. Now the first user has to enter a number of the subject of a student after that enter all subject marks and store the marks in an array. Now next step to add or find a sum of all subjects marks entered by the user and apply the formula and print the output calculated by the formula given.


System.out.print("Enter The 5 Subject Marks : ");

for(i=0; i<5; i++)
{
marks[i] = sc.nextInt();
sum = sum + marks[i];
}

System.out.print("\nStudent Percentage is = " +per+ "%\n\n");

Example:- Now take an example and check the output step by step. let's take 5 subjects in a semester and we have to calculate percentage out of total number 5 * 100 = 600.

Enter number of subjects: 5
Enter The Marks: 78 65 56 89 90
Percentage of a student: 75.6

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.Scanner;
/* Program By Ghanendra Yadav
    Visit http://www.programmingwithbasics.com/
*/
public class percentage
{
    public static void main(String args[])
    {
        int marks[] = new int[5];
        int i;
        float per,sum=0;

        Scanner sc = new Scanner(System.in);
 
        System.out.print("Enter The 5 Subject Marks : ");
        for(i=0; i<5 100="" i="" is=" +per+ " marks="" n="" nstudent="" per="(sum/500)" percentage="" pre="" sc.nextint="" sum="sum" system.out.print="">

 

Output:

Enter The 5 Subject Marks : 98

87

76

65

54

Student percentage is = 76.0%

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now