-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDMV.java
More file actions
46 lines (36 loc) · 1.18 KB
/
DMV.java
File metadata and controls
46 lines (36 loc) · 1.18 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
import java.util.Scanner;
public class DMV {
static Scanner scnr = new Scanner(System.in);
public static void generateDL(int age, boolean testPass) {
if (testPass == true && age >= 17) {
System.out.println("DL generated");
/* System.out.println("What year is it?");
int yearGenerated = scnr.nextInt();
System.out.println("Your license will expire in " + calculateExpirationDate(yearGenerated) + ".");
*/
}
else {
System.out.println("Cannot generate DL");
}
}
public static int calculateExpirationDate(int yearGenerated) {
return yearGenerated + 10;
}
public static void main(String[] args) {
int age;
boolean testPass;
System.out.println("Welcome. This program will tell you the expiration date for your license given that you are"
+ " the appropriate age and you passed your drivers test.");
System.out.println("Please enter your age.");
age = scnr.nextInt();
System.out.println("Did you pass your drivers test? (Y/N)");
String userInput = scnr.next();
if (userInput.equalsIgnoreCase("Y")) {
testPass = true;
}
else {
testPass = false;
}
generateDL(age, testPass);
}
}