Assignment (Question)
Assignment (Question)
Assignment 01
To design software that can calculate parking fare for customers who park their cars in a
parking lot.
Prerequisite Skills:
Basic knowledge of mathematical calculations
Understanding of C’s basic constructs (formatted I/O, expressions, operators, if control
structure)
Overview:
This system will calculate parking fare for customers who park their cars in a parking lot when
following information is given:
a. A character showing the type of vehicle: ‘C’ for car, ‘B’ for bus, ‘T’ for truck.
b. An integer between 0 and 24 showing the hour the vehicle entered the lot.
c. An integer between 0 and 60 showing the minute the vehicle entered the lot.
d. An integer between 0 and 24 showing the hour the vehicle left the lot.
e. An integer between 0 and 60 showing the minute the vehicle left the lot.
This is a public lot. To encourage people to park for a short period of time, the management uses
two different rates for each type of vehicle, as shown in table below.
No vehicle is allowed to stay in the parking lot later than midnight; any vehicle that remains past
midnight will be towed away.
The input data consist of a character (type of vehicle) and a set of four integers representing the
entering and leaving hours. But these pieces of data must be input into the computer in a user-
friendly way. In other words, the computer must prompt the user to enter each piece of data (as
shown on top of the next page).
Note: Since there are no fractional charges, the program must also round the parking time up to
the next hour before calculating the charges.
Assignment 01 Page 1 of 2
CC-112 Programming Fundamentals SPRING 2023
Sample Input/Output:
Input Output
C TYPE OF VEHICLE: CAR
14 TIME-IN: 14:23
23 TIME-OUT: 16:12
16 PARKING TIME: 02:11
12 ROUNDED TOTAL: $0.00
T TYPE OF VEHICLE: TRUCK
14 TIME-IN: 14:23
23 TIME-OUT: 16:12
16 PARKING TIME: 02:11
12 ROUNDED TOTAL: $2.00
B TYPE OF VEHICLE: BUS
14 TIME-IN: 14:23
23 TIME-OUT: 16:12
16 PARKING TIME: 02:11
12 ROUNDED TOTAL: $5.70
Integer (long)
Float
Boolean (contains TRUE and FALSE)
Assignment 01 Page 2 of 2