Monday, 19 December 2016

Java Program For Calculate Percentage Of 5 Subjects

Problem:- Java Program For Calculate Total Marks Of 5 Subjects And percentage.means yo have to give a variable size of a subject like 2,3,5 and more subject as the user wants and you need to calculate the percentage of marks and also print the marks of each subject.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

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.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

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

Explanation:- For this problem, I am taking 5 subjects. Now first user enter number of the subject of a student after that enter all subject marks and store the marks in an array, see the below part of the code.

printf("\nEnter number of subject : \n");
scanf("%d", &n);

scanf("%d", &arr[i]);

Now next step to add or a sum of all subjects marks entered by the user.


Now apply the formula and print the output calculated by the formula given.

Percentage = ( sum * 100 ) / tmp;

printf("\nPercentage Of Student : %d\n", Percentage);

here tmp is a number of subject * 100.

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

Enter number of subjects: 6 // 6 is user input

Enter The Marks: 78 65 56 89 45 90

Percentage of a student: 70.5

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Tip:- always read full post so you can understand better and check other solutions in different-different language. Share and like if you like and I also respect suggestion if you want any modification in the post or you have any better suggestion please let me know.

See Also:- C++ Program For Calculate Percentage Of 5 Subjects


/* Program By Ghanendra Yadav

import java.util.Scanner;

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.out.print("Enter The 5 Subject Marks : ");
        for(i=0; i<5; i++)
            marks[i] = sc.nextInt();
            sum = sum + marks[i];

        per = (sum/500) * 100;

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

See Also:- C Program For Calculate Percentage Of 5 Subjects


Java Program For Calculate Percentage Of 5 Subjects

You May Like This:-

1. Hacker Rank Solution for 30 Days of Code

2. Hacker Rank solution for Attribute Parser

3. Java Program For Find The Gross Salary Of An Employee

4. C++ Program For School Management System ( SMS Project ) With Source Code

5. Hacker Rank Solution For Mini-Max Sum

6. Hacker Rank Solution For Birthday Cake Candles

7. C++ Program For Store Employee Information And Display Using Structure

8. C Program For Find A Grade Of Given Marks Using Switch Case

9. C Program For HEAP Sort In Ascending Order Also Show Complexity

10. C++ Program For Selection Sort Using Function

No comments:
Write comments

Recommended Posts × +