|
HW 2.
Making Change!
Write a program that will output the proper change for any
reasonable dollars and cents input, let's say less than 100 dollars. For
instance, for an input of $19.56, your program should output:
one ten dollar bill,
one five dollar bill,
four one dollar bills,
two quarters,
one nickel,
and one penny
While an input of $11.49 would output:
one ten dollar bill,
one one dollar bill,
one quarter,
two dimes,
and four pennies
This assignment has several particulars, and several
teaching goals.
Particulars:
-
note the commas after all but the last lines
-
note the proper plurals, e.g. penny vs. pennies,
dime vs. dimes
-
note the "and" at the beginning of the last line
-
note that the change is correct! (this is actually
more important than you might think...MOST of you will encounter an
error in your math...this is a MIND OPENING exercise)
Teaching goals:
-
writing your first "real" program
-
use cin and
cout
-
introduction to logical statements and evaluations,
i.e. if(blah)
-
use of branching statements, i.e.
if (blah)....else (boo hoo)
-
introduction to C++ math
-
convert between variable types using
static_cast
-
problems with binary representation
|
Back to Programming Main Page
Back to John's Main Page
Allowable denominations
of change:
-
hundred dollar bill
-
fifty dollar bill
-
twenty dollar bill
-
ten dollar bill
-
five dollar bill
-
one dollar bill
-
quarter
-
dime
-
nickel
-
penny
|