-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarMaintenance.java
More file actions
148 lines (119 loc) · 4.38 KB
/
Copy pathCarMaintenance.java
File metadata and controls
148 lines (119 loc) · 4.38 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import java.util.Scanner;
import java.io.File;
import java.io.BufferedWriter;
import java.io.FileWriter;
public class CarMaintenance {
public static char printMenu() {
Scanner scnr = new Scanner(System.in);
char userOption;
System.out.println("");
System.out.println("MENU");
System.out.println("a - Enter address of repair shop(street, city, state, zip): ");
System.out.println("c - Enter cost of maintenance/repair: ");
System.out.println("d - Enter date of maintenance/repair: ");
System.out.println("e - Extra comments/notes about the maintenance/repair: ");
System.out.println("n - Enter name of repair shop: ");
System.out.println("p - Enter parts replaced: ");
System.out.println("t - Enter type of maintenance/repair: ");
System.out.println("w - Enter warranty information: ");
System.out.println("");
System.out.println("Choose an option(Enter q to quit): ");
userOption = scnr.next().charAt(0);
while((userOption != 'a') && (userOption != 'c') && (userOption != 'd') &&
(userOption != 'e') && (userOption != 'n') && (userOption != 'p') &&
(userOption != 't') && (userOption != 'w') && (userOption != 'q')) {
System.out.println("Invalid option. Choose another option:");
userOption = scnr.next().charAt(0);
}
return userOption;
}
public static String address() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter address of repair shop(street, city, state, zip): ");
String repAdd = scnr.nextLine();
return repAdd;
}
public static double cost() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter the cost of maintenance/repair: ");
double repCost = scnr.nextDouble();
return repCost;
}
public static String date() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter the date of maintenance/repair: ");
String repDate = scnr.nextLine();
return repDate;
}
public static String notes() {
Scanner scnr = new Scanner(System.in);
System.out.println("Extra comments/notes about the maintenance/repair: ");
String exNotes = scnr.nextLine();
return exNotes;
}
public static String name() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter name of the repair shop: ");
String repName = scnr.nextLine();
return repName;
}
public static String parts() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter parts replaced: ");
String repParts = scnr.nextLine();
return repParts;
}
public static String description() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter type of service: ");
String repType = scnr.nextLine();
return repType;
}
public static String warranty() {
Scanner scnr = new Scanner(System.in);
System.out.println("Enter warranty information: ");
String warInfo = scnr.nextLine();
return warInfo;
}
public static void main(String[] Args) {
Scanner scnr = new Scanner(System.in);
System.out.print("Enter user: ");
String user = scnr.nextLine();
System.out.println("User: " + user);
while(true) {
switch(printMenu()){
case 'q':
return;
case 't':
System.out.println("Description: " + description());
break;
case 'n':
System.out.println("Name: " + name());
break;
case 'a':
System.out.println("Address: " + address());
break;
case 'd':
System.out.println("Repair date: " + date());
break;
case 'c':
System.out.println("Cost: $" + cost());
break;
case 'p':
System.out.println("Parts Replaced: " + parts());
break;
case 'w':
System.out.println("Warranty: " + warranty());
break;
case 'e':
System.out.println("Comments: " + notes());
break;
}
}
}
}
/* Car Maintenance Print Info(PDF)
shows the program being ran,
with the user inputting the information
*/
// Ahmaad Jackson