' Cost of renting a car ' $26.59 per day, plus ' 31 cents per mile ' 3 days and 253 miles ' LET DAYS = 3 LET MILES = 253 PRINT "Cost is", 26.59 * DAYS + 0.31 * MILES END
Many other solutions to the above problem are possible. You could have made the cost a variable:
' Cost of renting a car ' $26.59 per day, plus ' 31 cents per mile ' 3 days and 253 miles ' LET DAYS = 3 LET MILES = 253 LET COST = 26.59 * DAYS + 0.31 * MILES PRINT "Cost is", COST END
This might make the program easier to understand since the calculation is done in one step and the printing is done is another.
The following version of the program has a bug in it. It prints out
Cost is 0
which is not likely to be the correct answer. Find the bug in the program.
' Cost of renting a car ' $26.59 per day, plus ' 31 cents per mile ' 3 days and 253 miles ' LET DAYS = 3 LET MILES = 253 LET COST = 26.59 * DAYS + 0.31 * MILES PRINT "Cost is", COSTS END