Write a C program to calculate the parking fare for customers who park their cars in a parking lot when the following information is given: a) A character showing the type of vehicle: C for car, B for bus, T for truck  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 the following table: Vehicle First Rate Second Rate CAR RM 0.00/hour first 3 hour RM 1.50/hour after 3 hour TRUCK RM 1.00/hour first 2 hour RM 2.30/hour after 2 hour BUS RM 2.00/hour for first hour RM 3.70/hour after first hour The input data consist of a character and a set of four integers representing the type of vehicle and the entering and leaving hours and minutes. 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 show below. (Note: Red colour indicates typical data) Type of vehicle? C Hour vehicle entered lot (0-24)? 14 Minute vehicle entered lot (0-60)? 23 Hour vehicle left lot (0-24)? 18 Minute vehicle left lot (0-60)? 8

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 4PE: 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and...
icon
Related questions
Question

Write a C program to calculate the parking fare for
customers who park their cars in a parking lot when the following information is
given:
a) A character showing the type of vehicle: C for car, B for bus, T for truck
 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 the
following table:

Vehicle First Rate Second Rate
CAR RM 0.00/hour first 3 hour RM 1.50/hour after 3 hour
TRUCK RM 1.00/hour first 2 hour RM 2.30/hour after 2 hour
BUS RM 2.00/hour for first hour RM 3.70/hour after first hour

The input data consist of a character and a set of four integers representing the
type of vehicle and the entering and leaving hours and minutes. 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 show
below. (Note: Red colour indicates typical data)

Type of vehicle? C
Hour vehicle entered lot (0-24)? 14
Minute vehicle entered lot (0-60)? 23
Hour vehicle left lot (0-24)? 18
Minute vehicle left lot (0-60)? 8

The output format is shown below:
This program must first calculate the actual time spent in the parking lot for
each vehicle. You may use the following algorithm:

a) Compare the minute portion of the leaving and the entering time. If the first
one is smaller than the second,
- Add 60 to the minute portion of the leaving time
- Subtract 1 from the hour portion of the leaving time
 Subtract the hour portions
c) Subtract the minute portions
d) Since there are no fractional hour charges, the program must also round the
parking time up to the next hour before calculating the charge. The program
should use switch statement to distinguish between the different types of
vehicles
A well-structured program design is required. Run your program six times with
the following data:

Test Type Hour In Minute In Hour Out Minute Out
1 C 12 40 14 22
2 B 8 20 8 40
3 T 2 0 3 59
4 C 12 40 16 22
5 B 8 20 14 20
6 T 2 0 12 0

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr