Repository navigation
Expand file tree
/
Copy pathStudentPassClass.java
More file actions
43 lines (37 loc) · 1.48 KB
/
Copy pathStudentPassClass.java
File metadata and controls
43 lines (37 loc) · 1.48 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
import java.util.Scanner;
public class StudentPassClass{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String continueChoice;
do {
System.out.print("Enter student's percentage (0–100): ");
int percentage = scanner.nextInt();
// Map percentage to tens place for switch
int band = percentage / 10;
switch (band) {
case 10: // covers 100%
case 9: // 90–99
case 8: // 80–89 → more than 85 goes here too
if (percentage > 85) {
System.out.println("First class with Distinction");
} else {
System.out.println("First class");
}
break;
case 7: // 70–79
case 6: // 60–69
System.out.println("First class");
break;
case 5: // 50–59
System.out.println("Second class");
break;
default: // 0–49 and any invalid entry
System.out.println("Fail");
}
System.out.print("Do you want to classify another student? (yes/no): ");
continueChoice = scanner.next();
} while (continueChoice.equalsIgnoreCase("yes"));
System.out.println("Program terminated.");
scanner.close();
}
}