Monday, 19 December 2016

Java Program For Calculate Percentage Of 5 Subjects

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

Logic :- First we will ask for total subject of student then we will enter marks of all those subject after that we will calculate a percentage of marks then we will print a student marks ,percentage and Grade of Student .Percentage formula are given Below. 

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

For This Problem I Am Taking 5 Subject.

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

Solution :- 

/* Program By Ghanendra Yadav
    Visit http://www.programmingwithbasics.com/
*/

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.in);

        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


Output:- 


Java Program For Calculate Percentage Of 5 Subjects

No comments:
Write comments

Recommended Posts × +