A parking lot charges different rates depending on the type of vehicle (C Semi, B- Bus). Туре Type Code First Rate Second Rate $2.00/hr after first 3 hours $6.25/hr after first 2 hours | 57.25hr after the first hour Car S1.75/hr first 3 hours Semi $5.25/hr first 2 hours $9.50hr first hour Bus в For example, if a bus has parked for 4 hours, then the total cost is calculated as follows: $9.50 (for the first 1 hours) + 3 x $7.25 (for the last three hours) = $31.25 Write a program named parking.cpp that does the following: • Prompts the user for the type of vehicle they are parking, use a char variable and the letters C, S, and B to track their vehicle information • Asks for the number of hours parked. For simplicity, all times are rounded up to the next hour (use ceil () from the library). • Calculates their total and then print a parking invoice as shown in the sample output • Terminate the program if the user entered an invalid vehicle type. Sample Output 1 - User Enters Invalid Vehicle Type Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): x+ That is an invalid vehicle type Sample Output 2 - Normal Program Execution Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus) : ce Enter the number of hours parked: 4.04 What is the license plate? ABC 1234 Vehicle Type: Car Time: 4 hours License Plate: ABC 123 Amount Due ($): 7.25

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Objectives
By completing this lab, students should be able to.
Write programs using conditional operators
Write programs using logical expressions
Write programs using getline ()
Background
Relational operators allow you to compare numerie, character, and string values to determine whether
me is greater than, less than, equal ta, or nat equal to another. A relational expressian evaluates one
or more variables using relational operatars to arrive at a Bšoolean (true or false) outcome. Consider
the following relatiomal operators and expressions:
Relational Operator
Relational Expression
Meaning
Is x grester thun y
Is x less than y?
Is x grester thum or l ay
Is x les than or equal to y!
Is x oqual to y?
x!-y
Is x not equal to y
Control structures are commands used in C++ to control the behavior of a program based on certain
criteria, such as user input. In this lah, you are being intraduced to the 'if" statement. There are
three different uses ofthe "i f" statement in C+: if, if/alse, and i f/else-if/else. In their
basic form, the following skeleton code templates implement these statements:
if (relatianal axprassior!
* Execate tale code il the rela ion.al expreesicn le true */
if (rclational expression)
* Execute code here if the expreasion is true /
else
/* Execule cude here if Lhe expression is false */
if (relational expreasion 11
A Fxecuta code tere if expression 1is true /
else if (relational expression 2)
/* Execute code here if expression 2 is true */
clse
/* Execute code here if ALL expressions are false /
Transcribed Image Text:Objectives By completing this lab, students should be able to. Write programs using conditional operators Write programs using logical expressions Write programs using getline () Background Relational operators allow you to compare numerie, character, and string values to determine whether me is greater than, less than, equal ta, or nat equal to another. A relational expressian evaluates one or more variables using relational operatars to arrive at a Bšoolean (true or false) outcome. Consider the following relatiomal operators and expressions: Relational Operator Relational Expression Meaning Is x grester thun y Is x less than y? Is x grester thum or l ay Is x les than or equal to y! Is x oqual to y? x!-y Is x not equal to y Control structures are commands used in C++ to control the behavior of a program based on certain criteria, such as user input. In this lah, you are being intraduced to the 'if" statement. There are three different uses ofthe "i f" statement in C+: if, if/alse, and i f/else-if/else. In their basic form, the following skeleton code templates implement these statements: if (relatianal axprassior! * Execate tale code il the rela ion.al expreesicn le true */ if (rclational expression) * Execute code here if the expreasion is true / else /* Execule cude here if Lhe expression is false */ if (relational expreasion 11 A Fxecuta code tere if expression 1is true / else if (relational expression 2) /* Execute code here if expression 2 is true */ clse /* Execute code here if ALL expressions are false /
A parking lot charges different rates depending on the type of vehicle (C - Car, S- Semi, B - Bus).
|Туре
Type Code First Rate
Second Rate
Car
S1.75/hr first 3 hours
$2.00/hr after first 3 hours
S5.25/hr first 2 hours
$6.25/hr after first 2 hours
Semi
Bus
B
$9.50/hr first hour
$7.25/hr after the first hour
For example, if a bus has parked for 4 hours, then the total cost is calculated as follows:
S9.50 (for the first 1 hours) + 3 x S7.25 (for the last three hours) - $31.25
Write a program named parking.cpp that does the following:
Prompts the user for the type of vehicle they are parking; use a char variable and the letters C,
S, and B to track their vehicle information
Asks for the number of hours parked. For simplicity, all times are rounded up to the next hour
(use ceil () from the <emath> library).
Calculates their total and then print a parking invoice as shown in the sample output
Terminate the program if the user entered an invalid vehicle type.
Sample Output 1 - User Enters Invalid Vehicle Type
Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus) : X4
That is an invalid vehicle type
Sample Output 2 - Normal Program Execution
Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): Ce
Enter the number of hours parked: 4.04
What is the license plate? ABC 123e
Vehicle Type: Car
Time: 4 hours
License Plate: ABC 123
Amount Due ($): 7.25
Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): S*
Enter the number of hours parked: 9.44
What is the license plate? JCD 86784
Vehicle Type: Semi
Time: 10 hours
License Plate: JCD 8678
Amount Due ($): 60.50
Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): Be
Enter the number of hours parked: 2.74
What is the license plate? SBS 45564
Vehicle Type: Bus
Time: 3 hours
License Plate: SBS 4556
Amount Due ($): 24.00
Transcribed Image Text:A parking lot charges different rates depending on the type of vehicle (C - Car, S- Semi, B - Bus). |Туре Type Code First Rate Second Rate Car S1.75/hr first 3 hours $2.00/hr after first 3 hours S5.25/hr first 2 hours $6.25/hr after first 2 hours Semi Bus B $9.50/hr first hour $7.25/hr after the first hour For example, if a bus has parked for 4 hours, then the total cost is calculated as follows: S9.50 (for the first 1 hours) + 3 x S7.25 (for the last three hours) - $31.25 Write a program named parking.cpp that does the following: Prompts the user for the type of vehicle they are parking; use a char variable and the letters C, S, and B to track their vehicle information Asks for the number of hours parked. For simplicity, all times are rounded up to the next hour (use ceil () from the <emath> library). Calculates their total and then print a parking invoice as shown in the sample output Terminate the program if the user entered an invalid vehicle type. Sample Output 1 - User Enters Invalid Vehicle Type Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus) : X4 That is an invalid vehicle type Sample Output 2 - Normal Program Execution Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): Ce Enter the number of hours parked: 4.04 What is the license plate? ABC 123e Vehicle Type: Car Time: 4 hours License Plate: ABC 123 Amount Due ($): 7.25 Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): S* Enter the number of hours parked: 9.44 What is the license plate? JCD 86784 Vehicle Type: Semi Time: 10 hours License Plate: JCD 8678 Amount Due ($): 60.50 Enter the vehicle type ('C' for car, 's' for semi, 'B' for bus): Be Enter the number of hours parked: 2.74 What is the license plate? SBS 45564 Vehicle Type: Bus Time: 3 hours License Plate: SBS 4556 Amount Due ($): 24.00
Expert Solution
Introduction

This is a simple cpp question where we use logical or operator and relational operators in if else conditions to check that whether the vehicle type is car, semi or bus. After checking the type we then calculate the due amount according to the price chart for each respective vehicle. Moreover for no of hours in decimal, we calculate the ceil value that means that the next integral number for the decimal number given. For that we used ceil function in cmath library present in c++.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY