CSCI 151 Fall 2014 Lab 11 Assignment
In USA, each state has different rules for license plates. In this program we will assume that all cars in NJ have 6 digit number license plates,
all cars in NY have 7 digit number license plates
, and all cars in RI have 4 or 5 digit number license plates.
Your program will read
a number of cars in the parking lot, license plate for each car,
and finds the number of cars from each of the 3 states listed above
(NJ,
NY, RI).
Write the following functions:
- count_digit(num) - finds and returns the number of digits
of the parameter num. Assume that num is positive.
- state(license_plate) - has one parameter - license plate. The function
returns 1, if the car from NJ, 2 - from NY, 3 - from RI. This function
will use function count_digit
- parking(num_cars) - has one parameter, number of cars in the parking
lot. The function reads the license plate for each car in the parking
lot.
The function finds and returns three values: the number of cars from NJ,
NY and RI. This function will use function state to determine the state
for each car
- write main that reads the number of cars
and finds the number of cars from each of the 3 states listed above
(NJ,
NY, RI).
Pay attention: your input for license plate number could be ANY POSITIVE INTEGER.
And
your
program will ignore any numbers that are shorter than 4 digits and longer than 7 digits
since they don't belong to any state.