Correct (debug) the following pseudocode: // This pseudocode segment is intended
ID: 3628712 • Letter: C
Question
Correct (debug) the following pseudocode:// This pseudocode segment is intended to compute the cost per
// day for a vacation. The user enters a value for total dollars
// available to spend and can continue to enter new dollar amounts
// while the amount entered is not 0. For each new amount entered,
// if the amount of money available to spend per day is below $100,
// a message is displayed.
input totalDollarsAvailable
while totalDollarsAvailable not = 0
dollarsPerDay = totalMoneyAvailable / 7
output dollarsPerDay
endwhile
input totalDollarsAvailable
if dollarsPerDay > 100 then
output “You'd better search for a bargain vacation”
endwhile
HINTS: There are two “endwhiles” and only one “while”. At least one statement is correct, but not in the correct place. The requirement is to display a message if the amount is below $100.
Explanation / Answer
input totalDollarsAvailable
while totalDollarsAvailable not = 0
dollarsPerDay = totalMoneyAvailable / 7
output dollarsPerDay
if dollarsPerDay < 100 then
output “You'd better search for a bargain vacation”
input totalDollarsAvailable
endwhile