pseudocode only he following problems, in the author\'s pseudocode as presented
ID: 3603054 • Letter: P
Question
pseudocode only
he following problems, in the author's pseudocode as presented in the text book up to this point, and with each exercise completed as described in the instructions below.
1) A rental car company requires a car return program that allows works as follows:
a. Assumes a maximum of 500 rentals, i.e., it is possible to have fewer than 500 rentals, just not more than that number
b. The program must allow an employee to enter:
i. The rental ID, e.g., “EL101”
ii. The beginning odometer reading noted on the rental contract
iii. The ending odometer reading from the car
iv. The base rental charge that the customer has paid when renting the vehicle
c. The program must allow the user to continuously enter this input, but allow them to stop by entering “ZZ999” for the rental ID
d. For each customer, the program must calculate and output the additional amount owed, if any, which is determined as follows:
i. All customers are allowed 500 miles as part of the base rental charge
ii. For up to 150 miles over the allowed 500, the customer has to pay an additional $2 per mile
iii. For any excess beyond 150 miles, the customer must pay $3 per mile
iv. A tax of 6.5% is applied on the calculated amount – output the amount before tax, the dollar amount of the tax itself, and the total after tax
e. When the user stops data entry, the program must determine and output:
i. The most miles driven by a customer, and output that along with the
ii. The least miles driven and output that along with the rental ID
iii. The total additional amount collected from customers
iv. The average amount collected from customers
v. The total revenue from rentals, which would include both the base rental charges and the additional amounts collected
f. The program must also allow the user to enter a rental ID, then search for that ID and if it is found, display all information pertaining to that rental – the ID, odometer readings, base rental charge, additional amounts before and after tax, and the tax itself, all in the correct order as you would expect to see on a bill or statement
Explanation / Answer
Declare structure to hold the rental id ,start odometer , end odometer, base rental charge,amount before tax, amount after tax, additional amount
Receive rental id, start odometer, end odometer, base rental
max_dist = end odometer - start odometer
min_dist = end odometer - start odometer
total_additional_amount = 0
total_amount = 0
total_revenue = 0
count = 1
while (rental_id ! = "ZZ999"):
Receive rental id, start odometer, end odometer
if (rental_id == "ZZ999")
break;
dist = end odometer - start odometer
if (dist > max_dist)
max_dist = dist
if (dist < min_dist)
min_dist = dist
if (dist <= 650):
additional_amt = (650 -dist) * 2
if (dist > 650):
additional_amt = (dist -650) * 3 + 150 * 2
total_additional_amount = total_additional_amount + additional_amt
total_amount = total_amount + base_rental
total_amount_before_tax = base_rental + additional_amt
total_amount_after_tax = total_amount_before_tax + 6.5 % of total_amount_before_tax
total_revenue = total_revenue + total_amount_before_tax
count++
Display max_dist, min_dist,total_amount/count, total_revenue
Receive rental_id for search
found = 0
loop over the list structure:
if rental_id found:
display information
found = 1;
break
if found == 0
Display "Not found"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.