-
Notifications
You must be signed in to change notification settings - Fork 0
/
gradecalculator.java
72 lines (68 loc) · 1.68 KB
/
gradecalculator.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import java.util.*;
class gradecalculator
{
public static void main(){
int n,i,j=1;
int s[ ]=new int[10];int tot=0;
double avgper;
String grade=" ";
System.out.println(" Student grade calculator ");
System.out.println("Enter the number of subjects:");
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
System.out.println("Enter your marks obatined ot of 100 in:");
for(i=0;i<n;i++)
{
System.out.println("Subject"+j+":");
s[i]=sc.nextInt();
j++;
}
for(i=0;i<n;i++)
{
tot+=s[i];
}
avgper=((tot)/(n*100))*100;
if(avgper>=99.0 && avgper<=100.0)
grade="A+";
else
if(avgper>=96.0 && avgper<99.0)
grade="A";
else
if(avgper>=90.0 && avgper<94.0)
grade="A-";
else
if(avgper>=87.0 && avgper<90.0)
grade="B+";
else
if(avgper>=85.0 && avgper<87.0)
grade="B";
else
if(avgper>=80.0 && avgper<85.0)
grade="B-";
else
if(avgper>=77.0 && avgper<80.0)
grade="C+";
else
if(avgper>=75.0 && avgper<77.0)
grade="C";
else
if(avgper>=70.0 && avgper<75.0)
grade="C-";
else
if(avgper>=67.0 && avgper<70.0)
grade="D+";
else
if(avgper>=65.0 && avgper<67.0)
grade="D";
else
if(avgper>=60.0 && avgper<65.0)
grade="D-";
else
if(avgper<60.0)
grade="F";
System.out.println("----RESULTS----");
System.out.println("Total Marks Obtained: "+tot+"/"+(n*100));
System.out.println("Average Percentage: "+avgper+"%");
System.out.println("Grade: "+grade);
}
}