質問編集履歴
2
追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -237,3 +237,11 @@
|
|
237
237
|
上のコードの下に履歴を表示させたいのですが、最新の5つの履歴の表示の仕方が、さっぱりわからず困っています。おそらく配列?を使って入力した値を集めるのかと思ったのですが、うまくいきませんでした。
|
238
238
|
|
239
239
|
非常に初歩的な質問で恐縮なのですが、回答いただけると助かります。
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
追記
|
244
|
+
|
245
|
+
すいません、、。設計の見直しというのも、どう直していいかわからないのですが課題に添付されていた設計?の流れの画像があったので貼ります。
|
246
|
+
|
247
|
+
![イメージ説明](4a221d68feb64a247184ff6a71c5d673.png)
|
1
修正点の編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,215 +4,213 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
```import java.util.Scanner;
|
8
|
+
|
9
|
+
public class CasherSystem{
|
10
|
+
|
11
|
+
public static void main(String[] args){
|
12
|
+
|
13
|
+
Scanner input=new Scanner(System.in);
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
System.out.println("=================================");
|
18
|
+
|
19
|
+
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
20
|
+
|
21
|
+
System.out.print("=================================");
|
22
|
+
|
23
|
+
System.out.println();
|
24
|
+
|
25
|
+
System.out.println("---------------------------------");
|
26
|
+
|
27
|
+
System.out.println("| MAIN MENU |");
|
28
|
+
|
29
|
+
System.out.println("---------------------------------");
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
System.out.println("Options");
|
34
|
+
|
35
|
+
System.out.println("1 - Checkout");
|
36
|
+
|
37
|
+
System.out.println("2 - Transaction History");
|
38
|
+
|
39
|
+
System.out.println("3 - Exit ");
|
40
|
+
|
41
|
+
System.out.println("Please select:");
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
int option = input.nextInt();
|
46
|
+
|
47
|
+
if(option == 1){
|
48
|
+
|
49
|
+
System.out.println("=================================");
|
50
|
+
|
51
|
+
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
52
|
+
|
53
|
+
System.out.print("=================================");
|
54
|
+
|
55
|
+
System.out.println();
|
56
|
+
|
57
|
+
System.out.println("---------------------------------");
|
58
|
+
|
59
|
+
System.out.println("| MAIN MENU |");
|
60
|
+
|
61
|
+
System.out.println("---------------------------------");
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
System.out.println("Options");
|
66
|
+
|
67
|
+
System.out.println("1 - Checkout");
|
68
|
+
|
69
|
+
System.out.println("2 - Transaction History");
|
70
|
+
|
71
|
+
System.out.println("3 - Exit ");
|
72
|
+
|
73
|
+
System.out.println("Please select:1");
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
System.out.println("---------------------------------");
|
78
|
+
|
79
|
+
System.out.println("| PAYMENT SECTION |");
|
80
|
+
|
81
|
+
System.out.println("---------------------------------");
|
82
|
+
|
83
|
+
System.out.println("Enter customer's bill");
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
double bill = input.nextDouble();
|
88
|
+
|
89
|
+
double tax = bill*0.12;
|
90
|
+
|
91
|
+
double total = bill+tax;
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
double[] history = bill,tax,total;
|
96
|
+
|
97
|
+
System.out.println("Enter custpmer's bill:"+bill);
|
98
|
+
|
99
|
+
System.out.printf("Price: $ %10.2f\n",bill);
|
100
|
+
|
101
|
+
System.out.printf("Tax : $ %10.2f\n",tax);
|
102
|
+
|
103
|
+
System.out.println("-------------------");
|
104
|
+
|
105
|
+
System.out.printf("Total: $ %10.2f\n",total);
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
System.out.println("Enter customer's payment:");
|
110
|
+
|
111
|
+
double pay = input.nextDouble();
|
112
|
+
|
113
|
+
double change = pay - total;
|
114
|
+
|
115
|
+
while(change<0){
|
116
|
+
|
117
|
+
System.out.printf("custermar's change:$%10.2f\n",change);
|
118
|
+
|
119
|
+
System.out.println("Warning:The customer's payment is not enough. Enter customer's payment again.");
|
120
|
+
|
121
|
+
pay = input.nextDouble();
|
122
|
+
|
123
|
+
change = pay - total;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
if(change>=0){
|
128
|
+
|
129
|
+
System.out.printf("custermar's change:$%10.2f\n",change);
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
System.out.println("=================================");
|
136
|
+
|
137
|
+
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
138
|
+
|
139
|
+
System.out.print("=================================");
|
140
|
+
|
141
|
+
System.out.println();
|
142
|
+
|
143
|
+
System.out.println("---------------------------------");
|
144
|
+
|
145
|
+
System.out.println("| MAIN MENU |");
|
146
|
+
|
147
|
+
System.out.println("---------------------------------");
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
System.out.println("Options");
|
152
|
+
|
153
|
+
System.out.println("1 - Checkout");
|
154
|
+
|
155
|
+
System.out.println("2 - Transaction History");
|
156
|
+
|
157
|
+
System.out.println("3 - Exit ");
|
158
|
+
|
159
|
+
System.out.println("Please select:");
|
160
|
+
|
161
|
+
option = input.nextInt();
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
|
166
|
+
|
7
|
-
|
167
|
+
if(option==2){
|
168
|
+
|
169
|
+
System.out.println("=================================");
|
170
|
+
|
171
|
+
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
172
|
+
|
173
|
+
System.out.print("=================================");
|
174
|
+
|
175
|
+
System.out.println();
|
176
|
+
|
177
|
+
System.out.println("---------------------------------");
|
178
|
+
|
179
|
+
System.out.println("| MAIN MENU |");
|
180
|
+
|
181
|
+
System.out.println("---------------------------------");
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
System.out.println("Options");
|
186
|
+
|
187
|
+
System.out.println("1 - Checkout");
|
188
|
+
|
189
|
+
System.out.println("2 - Transaction History");
|
190
|
+
|
191
|
+
System.out.println("3 - Exit ");
|
192
|
+
|
193
|
+
System.out.println("Please select:2");
|
194
|
+
|
195
|
+
System.out.println("---------------------------------");
|
196
|
+
|
197
|
+
System.out.println("| TRANSACTION HISTORY |");
|
198
|
+
|
199
|
+
System.out.println("---------------------------------");
|
200
|
+
|
201
|
+
System.out.println();
|
202
|
+
|
203
|
+
System.out.println(" History Sales Tax Total");
|
204
|
+
|
205
|
+
System.out.println("------------------------------------------------------");
|
206
|
+
|
207
|
+
|
8
208
|
|
9
209
|
コード
|
10
210
|
|
11
|
-
|
12
|
-
|
13
|
-
import java.util.Scanner;
|
14
|
-
|
15
|
-
public class CasherSystem{
|
16
|
-
|
17
|
-
public static void main(String[] args){
|
18
|
-
|
19
|
-
Scanner input=new Scanner(System.in);
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
System.out.println("=================================");
|
24
|
-
|
25
|
-
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
26
|
-
|
27
|
-
System.out.print("=================================");
|
28
|
-
|
29
|
-
System.out.println();
|
30
|
-
|
31
|
-
System.out.println("---------------------------------");
|
32
|
-
|
33
|
-
System.out.println("| MAIN MENU |");
|
34
|
-
|
35
|
-
System.out.println("---------------------------------");
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
System.out.println("Options");
|
40
|
-
|
41
|
-
System.out.println("1 - Checkout");
|
42
|
-
|
43
|
-
System.out.println("2 - Transaction History");
|
44
|
-
|
45
|
-
System.out.println("3 - Exit ");
|
46
|
-
|
47
|
-
System.out.println("Please select:");
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
int option = input.nextInt();
|
52
|
-
|
53
|
-
if(option == 1){
|
54
|
-
|
55
|
-
System.out.println("=================================");
|
56
|
-
|
57
|
-
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
58
|
-
|
59
|
-
System.out.print("=================================");
|
60
|
-
|
61
|
-
System.out.println();
|
62
|
-
|
63
|
-
System.out.println("---------------------------------");
|
64
|
-
|
65
|
-
System.out.println("| MAIN MENU |");
|
66
|
-
|
67
|
-
System.out.println("---------------------------------");
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
System.out.println("Options");
|
72
|
-
|
73
|
-
System.out.println("1 - Checkout");
|
74
|
-
|
75
|
-
System.out.println("2 - Transaction History");
|
76
|
-
|
77
|
-
System.out.println("3 - Exit ");
|
78
|
-
|
79
|
-
System.out.println("Please select:1");
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
System.out.println("---------------------------------");
|
84
|
-
|
85
|
-
System.out.println("| PAYMENT SECTION |");
|
86
|
-
|
87
|
-
System.out.println("---------------------------------");
|
88
|
-
|
89
|
-
System.out.println("Enter customer's bill");
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
double bill = input.nextDouble();
|
94
|
-
|
95
|
-
double tax = bill*0.12;
|
96
|
-
|
97
|
-
double total = bill+tax;
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
double[] history = bill,tax,total;
|
102
|
-
|
103
|
-
System.out.println("Enter custpmer's bill:"+bill);
|
104
|
-
|
105
|
-
System.out.printf("Price: $ %10.2f\n",bill);
|
106
|
-
|
107
|
-
System.out.printf("Tax : $ %10.2f\n",tax);
|
108
|
-
|
109
|
-
System.out.println("-------------------");
|
110
|
-
|
111
|
-
System.out.printf("Total: $ %10.2f\n",total);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
System.out.println("Enter customer's payment:");
|
116
|
-
|
117
|
-
double pay = input.nextDouble();
|
118
|
-
|
119
|
-
double change = pay - total;
|
120
|
-
|
121
|
-
while(change<0){
|
122
|
-
|
123
|
-
System.out.printf("custermar's change:$%10.2f\n",change);
|
124
|
-
|
125
|
-
System.out.println("Warning:The customer's payment is not enough. Enter customer's payment again.");
|
126
|
-
|
127
|
-
pay = input.nextDouble();
|
128
|
-
|
129
|
-
change = pay - total;
|
130
|
-
|
131
|
-
|
211
|
+
```
|
132
|
-
|
133
|
-
|
212
|
+
|
134
|
-
|
135
|
-
|
213
|
+
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
System.out.println("=================================");
|
142
|
-
|
143
|
-
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
144
|
-
|
145
|
-
System.out.print("=================================");
|
146
|
-
|
147
|
-
System.out.println();
|
148
|
-
|
149
|
-
System.out.println("---------------------------------");
|
150
|
-
|
151
|
-
System.out.println("| MAIN MENU |");
|
152
|
-
|
153
|
-
System.out.println("---------------------------------");
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
System.out.println("Options");
|
158
|
-
|
159
|
-
System.out.println("1 - Checkout");
|
160
|
-
|
161
|
-
System.out.println("2 - Transaction History");
|
162
|
-
|
163
|
-
System.out.println("3 - Exit ");
|
164
|
-
|
165
|
-
System.out.println("Please select:");
|
166
|
-
|
167
|
-
option = input.nextInt();
|
168
|
-
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
if(option==2){
|
174
|
-
|
175
|
-
System.out.println("=================================");
|
176
|
-
|
177
|
-
System.out.println("| WELCOME TO CIMP CASHER SYSTEM |");
|
178
|
-
|
179
|
-
System.out.print("=================================");
|
180
|
-
|
181
|
-
System.out.println();
|
182
|
-
|
183
|
-
System.out.println("---------------------------------");
|
184
|
-
|
185
|
-
System.out.println("| MAIN MENU |");
|
186
|
-
|
187
|
-
System.out.println("---------------------------------");
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
System.out.println("Options");
|
192
|
-
|
193
|
-
System.out.println("1 - Checkout");
|
194
|
-
|
195
|
-
System.out.println("2 - Transaction History");
|
196
|
-
|
197
|
-
System.out.println("3 - Exit ");
|
198
|
-
|
199
|
-
System.out.println("Please select:2");
|
200
|
-
|
201
|
-
System.out.println("---------------------------------");
|
202
|
-
|
203
|
-
System.out.println("| TRANSACTION HISTORY |");
|
204
|
-
|
205
|
-
System.out.println("---------------------------------");
|
206
|
-
|
207
|
-
System.out.println();
|
208
|
-
|
209
|
-
System.out.println(" History Sales Tax Total");
|
210
|
-
|
211
|
-
System.out.println("------------------------------------------------------");
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
214
|
|
217
215
|
|
218
216
|
|