-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay-03-Java-Q12
More file actions
80 lines (67 loc) · 1.91 KB
/
Day-03-Java-Q12
File metadata and controls
80 lines (67 loc) · 1.91 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*Dheena wants to know how the grading marks will works in education.could you please help him to learn the grading System. Note:-
100=Grade is S
90-99=Grade is A
80-89=Grade is B
70-79=Grade is C
60-69=Grade is D
50-59=Grade is E
<50=Fail
Get the subject marks from the user,then Find the average marks.Based on the average marks generate the Students grade marks.
Input Format
First input consists of String
Second input consists of integer
Third input consists of integer
Fourth input consists of integer
Fifth input consists of integer
Sixth input consists of integer
Constraints
No Constraints
Output Format
execute the total Marks,average marks and Grade Mark
Sample Input 0
John
100
99
100
100
99
Sample Output 0
Name of the Student:John
Total Mark:498
Average Mark:99.6
Grade Mark:A
Sample Input 1
Nivi
30
30
30
30
30
Sample Output 1
Name of the Student:Nivi
Total Mark:150
Average Mark:30.0
Grade Mark:Fail*/
#Answer
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name = sc.nextLine();
int m1 = sc.nextInt(), m2 = sc.nextInt(), m3 = sc.nextInt(), m4 = sc.nextInt(), m5 = sc.nextInt();
int total = m1 + m2 + m3 + m4 + m5;
double average = total / 5.0;
String grade = (average == 100) ? "S" :
(average >= 90) ? "A" :
(average >= 80) ? "B" :
(average >= 70) ? "C" :
(average >= 60) ? "D" :
(average >= 50) ? "E" : "Fail";
System.out.println("Name of the Student:" + name +
"\nTotal Mark:" + total +
"\nAverage Mark:" + average +
"\nGrade Mark:" + grade);
sc.close();
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
}
}