Write the selection statement within the pseudo code below in order to complete
ID: 3771988 • Letter: W
Question
Write the selection statement within the pseudo code below in order to complete the psuedo code.
A rental car company uses the following procedure to determine the total charges:
Car Type:
1 – Compact $30 per day/$195 per week
2 – Medium sized $45 per day/$285 per week
3 – Luxury $55 per day/$350 per week
Input (from user):
Car Type (1, 2, or 3)
Rent code - (1 = Daily or 2 = Weekly)
Number of days - (set to 0 if rented by the week. Customers cannot rent for more than 1 week.)
Output:
Customer’s Total Bill
Note that there is no need to validate the input.
***************** pseudo-code ***********************
numeric carType = 0
numeric rentCode = 0
numeric numDays = 0
numeric bill = 0
display "Please enter the type of car (1 - Compact, 2 - Medium, 3 - Luxury)"
read carType
display "Please enter the rent code (1 - Daily, 2 - Weekly)"
read rentCode
display "Please enter the number of days rented (0 if rented Weekly)"
read numDays
Explanation / Answer
Here is the selection statement for the given condition. Keep in mind that, there is more than one notation for pseudocode, and its all about making the flow of logic understandable to most of the people(not limited to programmers). If you have any further queries, just get back to me.
Customer’s Total Bill
Note that there is no need to validate the input.
***************** pseudo-code ***********************
numeric carType = 0
numeric rentCode = 0
numeric numDays = 0
numeric bill = 0
display "Please enter the type of car (1 - Compact, 2 - Medium, 3 - Luxury)"
read carType
display "Please enter the rent code (1 - Daily, 2 - Weekly)"
read rentCode
display "Please enter the number of days rented (0 if rented Weekly)"
read numDays
if carType == 1 and rentCode == 1
totalCharges = 30 * numDays
else if carType == 1 and rentCode == 2
totalCharges = 195
else if carType == 2 and rentCode == 1
totalCharges = 45 * numDays
else if carType == 2 and rentCode == 2
totalCharges = 285
else if carType == 3 and rentCode == 1
totalCharges = 55 * numDays
else if carType == 3 and rentCode == 2
totalCharges = 350
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.