Debugging Section Exercise #1 50 points Plus up to 10 points extra The following
ID: 3576354 • Letter: D
Question
Debugging Section Exercise #1 50 points Plus up to 10 points extra The following pseudocode contains errors. You must find 3 or more errors in each of the following programs. If you find more than 3 mistakes, you will earn extra credit points. This pseudocode should determine the rental fees for cars Standard cars rent for $65 per day. compacts rent for $40 per day and subcompacts rent for $30 per day Rentals for at least 7 days receive a 20 discount An error message is displayed if the car type is not valid The program exits when the user enters in Start Declarations string car Type num days num STD RATE 65 num COM RATE 40 num SUB RATE 30 num DAYS FOR DISCOUNT 7 num DISCOUNT RATE 0.20 string QUIT "zzzz" getReady while car Type QUIT detail Loop end while finish Stop getReady output Enter car type or QUIT to quit input carType return detail Loop output Enter days rented input days if car Type Standard then rate STD RATE else if car Type Compact then rate COM RATE else if car Type Subcompact then rate SUB RATEExplanation / Answer
C=current line
F=fixed line
Exercise #1:
=============
Errors in Declarations:
F:num rate -- missing
Errors in detailLoop() function:
C:if car_Type = "Compact" then
F:if carType = "Compact" then
C:if rate<>0
F:if rate<>0 then
if days>=DAYS_FOR_DISCOUNT then
rate=rate-rate*DISCOUNT_RATE
endif
F:endif //missing
C:output carType,days
F:output "Rental fees for ",carType," car for ",days, " days is ",rate
C:output "Enter car type or ",QUIT, " to quit
C:" --not required
C:input car_Type -- not required as the input is handled via getReady()
F:getReady()
Exercise #2
===========
Main section:
C://Declarations
F:Declarations
C:OutputFile allsales
F:OutputFile allSales
C: while bothAtEof > "N"
F: while bothAtEof = "N"
getReady() Function:
C:newSalesperson = NAME
F:newSalesperson = HIGH_NAME
C:oldSalesperson = NAME
F:oldSalesperson = HIGH_NAME
C:bothAtEof < "Y"
F:bothAtEof = "Y"
detailLoop() Function:
C: usedSalesperson = HIGHNAME
F: usedSalesperson = HIGH_NAME
C: output newSalesperson, newAmount to alllSales
F: output newSalesperson, newAmount to allSales
finish() function:
C: close allsales
F: close allSales
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.