-
Notifications
You must be signed in to change notification settings - Fork 164
/
Calculate marks
64 lines (60 loc) · 2.27 KB
/
Calculate marks
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
import java.util.*;
class New{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter Student Name : ");
String name = input.next();
System.out.print("Enter Student Address : ");
String address = input.next();
System.out.print("Enter Number of Subjects : ");
int number_of_subjects = input.nextInt();
int marks = 0;
int max = 0;
int total = 0;
System.out.println();
for(int i = 0 ; i < number_of_subjects ; i++){
System.out.print("Enter Subject " + (i + 1) + " Marks : ");
marks = input.nextInt();
if(max < marks){
max = marks;
}
total = total + marks;
}
boolean flag = true;
while(flag){
System.out.println();
System.out.println("A. Show Student Details.");
System.out.println("B. Show Maximum Marks.");
System.out.println("C. Show Result.");
System.out.println("X. Exit");
System.out.println();
System.out.print("Please select one option : ");
String letter = input.next();
System.out.println();
switch(letter){
case "A":
System.out.println("Student Name : " + name);
System.out.println("Student Address : " + address);
break;
case "B":
System.out.println("Maximum Marks : " + max);
break;
case "C":
double average = (double)total /
number_of_subjects;
String result = "Fail";
if(average >= 50){
result = "Pass";
}
System.out.println("Result : " + result);
break;
case "X":
System.out.println("Good Bye......");
flag = false;
break;
default :
System.out.println("Please select valid option");
}
}
}
}