-
Notifications
You must be signed in to change notification settings - Fork 0
/
interstate.java
33 lines (30 loc) · 1.5 KB
/
interstate.java
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
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int highwayNumber;
highwayNumber = scnr.nextInt();
if ((highwayNumber % 2 == 0) && (highwayNumber % 100 != 00)) {
if (highwayNumber > 0 && highwayNumber < 100) {
System.out.println("I-" + highwayNumber + " is primary, going east/west.");
}
else if (highwayNumber >= 100 && highwayNumber <= 999) {
System.out.println("I-" + highwayNumber + " is auxiliary, serving I-" + (highwayNumber % 100) + ", going east/west.");
}
}
else if ((highwayNumber % 2 != 0) && (highwayNumber % 100 != 00)) {
if (highwayNumber > 0 && highwayNumber < 100) {
System.out.println("I-" + highwayNumber + " is primary, going north/south.");
}
else if (highwayNumber >= 100 && highwayNumber <= 999) {
System.out.println("I-" + highwayNumber + " is auxiliary, serving I-" + (highwayNumber % 100) + ", going north/south.");
}
}
else if ((highwayNumber <= 0) || (highwayNumber >= 1000)) {
System.out.println(highwayNumber + " is not a valid interstate highway number.");
}
else if (highwayNumber % 100 == 00) {
System.out.println(highwayNumber + " is not a valid interstate highway number.");
}
}
}