19/12/2016

Java Program For Calculate Percentage of 5 Subjects

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.

Check This:- HackerRank solution for C++ Domain.

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


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

Java Program For Calculate Percentage of 5 Subjects



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="">

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

Output:-

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: