int t[1..3]
int n=0
while (n≠0) {
read n
if(n<0) {print error}
else if (n <= 3) {
t[n]++
}
}
for (n=1..3) {
printf "There are %d cars of type %d.",t[n],n
}
Input in a number representing a car type, until the number 0 is
input. There are three types of cars: 1 = luxury, 2 = commercial, 3 =
sedan.
Count how many of each type there are and print out this total with a
message stating what type of car it is.
1 answer