質問編集履歴
1
進展させました
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,21 +24,25 @@
|
|
24
24
|
|
25
25
|
import java.io.FileNotFoundException;
|
26
26
|
|
27
|
+
import java.io.PrintWriter;
|
28
|
+
|
27
29
|
|
28
30
|
|
29
31
|
class Account {
|
30
32
|
|
31
33
|
private float balance;
|
32
34
|
|
35
|
+
|
36
|
+
|
33
37
|
private int countDp;
|
34
38
|
|
35
39
|
private int countWd;
|
36
40
|
|
37
41
|
|
38
42
|
|
39
|
-
float[] deposit = new float[
|
43
|
+
float[] deposit = new float[10];
|
40
|
-
|
44
|
+
|
41
|
-
float[] withdrawal = new float[
|
45
|
+
float[] withdrawal = new float[10];
|
42
46
|
|
43
47
|
|
44
48
|
|
@@ -58,6 +62,24 @@
|
|
58
62
|
|
59
63
|
|
60
64
|
|
65
|
+
private float[] enhanceArray(float[] array) {
|
66
|
+
|
67
|
+
float[] newArray = new float[array.length + 10];
|
68
|
+
|
69
|
+
for (int i = 0; i < array.length; i++) {
|
70
|
+
|
71
|
+
newArray[i] = array[i];
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
return newArray;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
61
83
|
public float depositing() {
|
62
84
|
|
63
85
|
System.out.println("Enter the amount you would like to deposit: ");
|
@@ -68,6 +90,14 @@
|
|
68
90
|
|
69
91
|
|
70
92
|
|
93
|
+
if (countDp == deposit.length) {
|
94
|
+
|
95
|
+
deposit = enhanceArray(deposit);
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
deposit[countDp] = depositAmount;
|
100
|
+
|
71
101
|
balance += depositAmount;
|
72
102
|
|
73
103
|
|
@@ -90,17 +120,27 @@
|
|
90
120
|
|
91
121
|
|
92
122
|
|
93
|
-
if (balance >= withdrawalAmount)
|
123
|
+
if (balance >= withdrawalAmount) {
|
124
|
+
|
125
|
+
if (countWd == deposit.length) {
|
126
|
+
|
127
|
+
withdrawal = enhanceArray(withdrawal);
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
withdrawal[countDp] = withdrawalAmount;
|
94
132
|
|
95
133
|
balance -= withdrawalAmount;
|
96
134
|
|
135
|
+
countWd += 1;
|
136
|
+
|
97
|
-
else {
|
137
|
+
} else {
|
98
138
|
|
99
139
|
System.out.println("Less balance, transaction failed.");
|
100
140
|
|
101
141
|
}
|
102
142
|
|
103
|
-
|
143
|
+
|
104
144
|
|
105
145
|
return balance;
|
106
146
|
|
@@ -114,29 +154,17 @@
|
|
114
154
|
|
115
155
|
}
|
116
156
|
|
117
|
-
|
157
|
+
|
118
158
|
|
119
159
|
public void outputAllDeposits() {
|
120
160
|
|
121
|
-
// while(input.hasNextFloat()) {
|
122
|
-
|
123
|
-
// deposit[countDp] = input.nextFloat();
|
124
|
-
|
125
|
-
// float line = deposit[countDp];
|
126
|
-
|
127
|
-
// countDp += 1;
|
128
|
-
|
129
|
-
// System.out.println(line);
|
130
|
-
|
131
|
-
// }
|
132
|
-
|
133
161
|
|
134
162
|
|
135
163
|
System.out.println("Outputting all your deposits:");
|
136
164
|
|
137
165
|
|
138
166
|
|
139
|
-
for (int i = 0; i <
|
167
|
+
for (int i = 0; i < countDp; i++) {
|
140
168
|
|
141
169
|
deposit[i] = input.nextFloat();
|
142
170
|
|
@@ -144,7 +172,7 @@
|
|
144
172
|
|
145
173
|
if(deposit[i] >= 0.0f) {
|
146
174
|
|
147
|
-
System.out.println(deposit[i]);
|
175
|
+
System.out.println("$" + deposit[i]);
|
148
176
|
|
149
177
|
}
|
150
178
|
|
@@ -160,7 +188,7 @@
|
|
160
188
|
|
161
189
|
|
162
190
|
|
163
|
-
for (int i = 0; i <
|
191
|
+
for (int i = 0; i < countWd; i++) {
|
164
192
|
|
165
193
|
withdrawal[i] = input.nextFloat();
|
166
194
|
|
@@ -168,7 +196,7 @@
|
|
168
196
|
|
169
197
|
if(withdrawal[i] >= 0.0f) {
|
170
198
|
|
171
|
-
System.out.println(withdrawal[i]);
|
199
|
+
System.out.println("$" + withdrawal[i]);
|
172
200
|
|
173
201
|
}
|
174
202
|
|
@@ -254,10 +282,14 @@
|
|
254
282
|
|
255
283
|
Account account = new Account();
|
256
284
|
|
285
|
+
|
286
|
+
|
257
287
|
Scanner in = new Scanner(System.in);
|
258
288
|
|
259
289
|
|
260
290
|
|
291
|
+
|
292
|
+
|
261
293
|
do {
|
262
294
|
|
263
295
|
System.out.println("**************************************\n" +
|
@@ -348,6 +380,4 @@
|
|
348
380
|
|
349
381
|
}
|
350
382
|
|
351
|
-
|
352
|
-
|
353
383
|
```
|