-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
62 lines (50 loc) · 1.48 KB
/
Main.java
File metadata and controls
62 lines (50 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @exercise: Vida de Estudante
* @author: Rodrigo Andrade
* @date: 25 Feb 2026
* @license: MIT
* @language: Java
* @github: https://github.com/Rorchive/C06
*/
package com.rodrigoandrade;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("NPA score:");
Scanner input = new Scanner(System.in);
// Using bytes for memory efficiency
byte npa;
// Checking if -128 <= NPA <= 127 (byte overflow)
try {
npa = input.nextByte();
} catch (Exception e) {
input.close();
System.out.println("Invalid score.");
return;
}
if (npa >= 60) {
System.out.println("Approved.");
}else if (npa >= 30 && npa < 60) {
System.out.println("You need to do NP3.");
System.out.println("NP3 score:");
byte np3;
try {
np3 = input.nextByte();
} catch (Exception e) {
input.close();
System.out.println("Invalid score.");
return;
}
float nfa = (np3 + npa)/(float)(2.0);
System.out.printf("NFA: %.2f\n", nfa);
if (nfa >= 60) {
System.out.println("Approved.");
}else {
System.out.println("Failed.");
}
}else {
System.out.println("Failed.");
}
input.close();
}
}