-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudentGradeCalculator
More file actions
55 lines (53 loc) · 1.58 KB
/
studentGradeCalculator
File metadata and controls
55 lines (53 loc) · 1.58 KB
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
import java.util.Scanner;
import java.util.*;
class studentGradeCalculator
{
public static void main (String [] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter The number of subjects : ");
int numofSubjects = sc.nextInt();
String[] subjectNames = new String[numofSubjects];
float[] marks = new float[numofSubjects];
for (int i=0;i<numofSubjects;i++)
{
System.out.println ("Enter subject no. : "+(i+1));
subjectNames[i] = sc.nextLine();
System.out.println ("Enter marks obtained :");
marks[i]=sc.nextFloat();
}
float sum=0.0f;
for(int i=0;i<marks.length;i++)
{
sum+=marks[i];
}
System.out.println ("Total length:"+sum);
float percentage=sum/numofSubjects;
System.out.printf("Average Marks: %0.2f",percentage);
if (percentage>=95 && percentage<=100)
{
System.out.print("\n Grade is A+.");
}
else if (percentage>=85 && percentage<94)
{
System.out.print("\n Grade is A.");
}
else if (percentage>=75 && percentage<84)
{
System.out.print("\n Grade is B+.");
}
else if (percentage>=65 && percentage<74)
{
System.out.print("\n Grade is B.");
}
else if (percentage>=55 && percentage<64)
{
System.out.print("\n Grade is C+.");
}
else
{
System.out.print("\n Grade is F.");
}
return;
}
}