-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGrader.java
More file actions
38 lines (35 loc) · 1.03 KB
/
Grader.java
File metadata and controls
38 lines (35 loc) · 1.03 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
import java.util.Scanner;
@FunctionalInterface
interface Grading{
abstract String grade(double mark);
}
public class Grader {
public static void main(String args[]) {
Grading grader = (double mark) -> {
if(mark >= 70 && mark <= 100){
return "A";
}else if(mark >= 60){
return "B";
}else if(mark >= 50){
return "C";
}else if(mark >= 40){
return "D";
}else if(mark > 0){
return "FAIL";
}else{
return "INVALID";
}
};
Scanner input = new Scanner(System.in);
System.out.print("\n --- System Online [Ready to Grade] --- ");
while(true){
try{
System.out.print("\n\t Enter mark: ");
double mark = input.nextDouble();
System.out.println("\t\t grade: " + grader.grade(mark));
}catch(Exception e){
break;
}
}
}
}