Chap 1 - Debugging Examples
// This program accepts a user's monthly pay, rent, utilities, and grocery bills and displays the amount available for discretionary // spending (which might be negative). Modify the program to output the pay and the total bills as well as the remaining // discretionary amount start input pay input rent input utilities input groceries discretionary = pay - rent - utlilities - groceries output discretionary stop To fix this, the program should be changed to the following: start input pay input rent input utilities input groceries ____________________ = rent + utlilities + groceries discretionary = pay - _____________________________ output pay output ________________________ output discretionary stop
// This program accepts a user's monthly pay, rent, utilities, and grocery bills and displays the amount available for discretionary // spending (which might be negative). Modify the program to output the pay and the total bills as well as the remaining // discretionary amount start input pay input rent input utilities input groceries discretionary = pay - rent - utlilities - groceries output discretionary stop To fix this, the program should be changed to the following: start input pay input rent input utilities input groceries [totalBills] = rent + utlilities + groceries discretionary = pay - [totalBills] output pay output [totalBills] output discretionary stop
// This pseudocode is intended to compute the number // of miles per gallon you get with your automobile. start input milesTraveled input gallonsOfGasUsed milesPerGallon = milesTraveled (___) __________ output __________________ start
// This pseudocode is intended to compute the number // of miles per gallon you get with your automobile. start input milesTraveled input gallonsOfGasUsed milesPerGallon = milesTraveled [/] gallonsOfGasUsed output milesPerGallon start
// This pseudocode is intended to describe // computing the price of an item on sale for 10% off start input origPrice discount = _______ * _______ finalPrice = origPrice - ___________ output _________ stop
// This pseudocode is intended to describe // computing the price of an item on sale for 10% off start input origPrice discount = origPrice * 0.10 finalPrice = origPrice - discount output finalPrice stop