Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d838336

Browse files
Create 26.2 Grade Calculator.java
1 parent ff3495e commit d838336

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

‎26.2 Grade Calculator.java‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
It's PTM tomorrow in Cambridge School.Teachers want to show the grades from(A to E) depending on the percentage of the student. Help the teacher's by developing the program for the same.To find the grade of a student, given the marks of N subjects. Given the marks of N subjects, we have to print the grade of a student based on the following grade slab.
3+
4+
If Percentage Marks > 90, Grade is A+ If 70 <= Percentage Marks <= 89, Grade is A If 60 <= Percentage Marks <= 69, Grade is B If 50 <= Percentage Marks <= 59, Grade is C If Percentage Marks <= 40, Grade is D
5+
6+
Input Format
7+
8+
Integer Value to enter number of subjects, count Enter marks of subjects depending upon the the total number of subjects
9+
10+
Constraints
11+
12+
Number of subjects should not exceed 7
13+
14+
Output Format
15+
16+
Character output to show grades
17+
18+
Sample Input 0
19+
20+
5
21+
50 57 89 87 56
22+
Sample Output 0
23+
24+
B
25+
Sample Input 1
26+
27+
9
28+
Sample Output 1
29+
30+
Invalid
31+
*/
32+
import java.io.*;
33+
import java.util.*;
34+
35+
public class Solution {
36+
37+
public static void main(String[] args) {
38+
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
39+
Scanner sc = new Scanner(System.in);
40+
int n = sc.nextInt();
41+
if(n>0 && n<=7)
42+
{
43+
int []marks = new int[n];
44+
int sum = 0;
45+
for(int i=0;i<n;i++)
46+
{
47+
marks[i] = sc.nextInt();
48+
sum += marks[i];
49+
}
50+
int precentage = sum / n;
51+
if(precentage>90)
52+
System.out.print("A+");
53+
else if(precentage>=70 && precentage<=89)
54+
System.out.print("A");
55+
else if(precentage>=60 && precentage<=69)
56+
System.out.print("B");
57+
else if(precentage>=50 && precentage<=59)
58+
System.out.print("C");
59+
else if(precentage<=40)
60+
System.out.print("D");
61+
}
62+
else{
63+
System.out.print("Invalid");
64+
}
65+
}
66+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /