回答編集履歴
2
改正
test
CHANGED
@@ -155,3 +155,83 @@
|
|
155
155
|
}
|
156
156
|
|
157
157
|
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
エラー発生部分ではないかと思える場所を削ったものが以下です
|
162
|
+
|
163
|
+
```java
|
164
|
+
|
165
|
+
import java.util.*;
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
public class TPU
|
170
|
+
|
171
|
+
{
|
172
|
+
|
173
|
+
public static void main(String args[])
|
174
|
+
|
175
|
+
{
|
176
|
+
|
177
|
+
Scanner scanner= new Scanner(System.in);
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
System.out.println("How many people in your family?");
|
182
|
+
|
183
|
+
int number = scanner.nextInt();
|
184
|
+
|
185
|
+
int a[] = new int[500];
|
186
|
+
|
187
|
+
int sum = 0;
|
188
|
+
|
189
|
+
for(int x = 0; x < number; x++)
|
190
|
+
|
191
|
+
{
|
192
|
+
|
193
|
+
System.out.print("Enter their age:");
|
194
|
+
|
195
|
+
int age = scanner.nextInt();
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
if(age <= 15)
|
200
|
+
|
201
|
+
{
|
202
|
+
|
203
|
+
System.out.println("No insurance needed");
|
204
|
+
|
205
|
+
a[x] = 0;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
}
|
210
|
+
|
211
|
+
if(age >= 16 && age <= 19) {
|
212
|
+
|
213
|
+
a[x] = 1150; }
|
214
|
+
|
215
|
+
if(age >= 20 && age <= 24) {
|
216
|
+
|
217
|
+
a[x] = 1050; }
|
218
|
+
|
219
|
+
if(age >= 25) {
|
220
|
+
|
221
|
+
a[x] = 900;}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
sum += a[x];
|
226
|
+
|
227
|
+
System.out.println("The total price is" + sum + "$");
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
```
|
1
改正
test
CHANGED
@@ -75,3 +75,83 @@
|
|
75
75
|
}
|
76
76
|
|
77
77
|
```
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
別の方法で実行するものが以下です
|
82
|
+
|
83
|
+
```java
|
84
|
+
|
85
|
+
import java.util.*;
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
public class TPQ
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
public static void main(String args[])
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
try(Scanner scanner= new Scanner(System.in))
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
System.out.println("How many people in your family?");
|
102
|
+
|
103
|
+
int number = scanner.nextInt();
|
104
|
+
|
105
|
+
int a=0;
|
106
|
+
|
107
|
+
int sum = 0;
|
108
|
+
|
109
|
+
for(int x = 0; x < number; x++)
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
System.out.print("Enter their age:");
|
114
|
+
|
115
|
+
int age = scanner.nextInt();
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
if(age <= 15)
|
120
|
+
|
121
|
+
{
|
122
|
+
|
123
|
+
System.out.println("No insurance needed");
|
124
|
+
|
125
|
+
a = 0;
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
if(age >= 16 && age <= 19) {
|
132
|
+
|
133
|
+
a = 1150; }
|
134
|
+
|
135
|
+
if(age >= 20 && age <= 24) {
|
136
|
+
|
137
|
+
a = 1050; }
|
138
|
+
|
139
|
+
if(age >= 25) {
|
140
|
+
|
141
|
+
a = 900;}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
sum += a;
|
146
|
+
|
147
|
+
System.out.println("The total price is" + sum + "$");
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
```
|