Need help on assignment

Assignment: DISBURSEMENT. 50 POINTS on time and correctly.

Here is the first thing I'll do when correcting these assignments:

coins.exe
1.14

coins.exe
1.13

If you end up with 3 and 2 pennies respectively, you have a
rounding error, the program isn't finished.

As always I provide you an "a.out" example.
To run the demo, log in to Buffy, copy them to your directory
cp ~hhaller/data/cisc192/asst1/a.out .

then: a.out

The Tale:

A player cashes a Money Order with you. Since Earth has been suffering
from a Martian Money Weevel plague (flying lightbulbs with teeth?) only
coins are legal tender now, so....

Convert their money into the MINIMUM NUMBER of coins, so it's not too heavy.
(Silver Dollars and Halves are out, since the Great Cartwheel Gopher
Strike of '24....) You may use Quarters, Dimes, Nickels, and Pennies.

Write a console application to convert the player's money
order into the minimum number of US Coins.

Prompt the user for a sum of money
"Total: DDDD.CC"
Input the user's response in the form DDDD.CC
Calculates the sum in US Coins: 25 cents, 10 cents, 5 cents, and 1 cent.
(Use the minimum number of coins and don't make
any rounding errors.) Output the totals:

Total: 12.34 quarters:49 dimes:0 nickles:1
pennies:4

Consider the % operator: 0 == 8 % 2 and 2 == 17 % 5.

% is the "modulus" operator, the remainder after dividing
the first number by the second. If this is a foreign
concept, use the textbook's INDEX to look up the modulus
operator and read about it. If you have trouble using an
alphabetic index, let me know so we can do something.

Be sure to check your work with pencil and paper or
a calculator.

============================
Remember:

Input the total amount into a variable of type double,
multiply the double by 100 to change the amount to total
pennies. Store (copy) THAT to an int, and use ints from then on.
If you do those steps out of order, expect chaos, so test for it.

For instance:

double total ;

cin >> total ;
total *= 100 ;
int pennies = total ; // will probably work.

BUT:

cin >> total ;
int pennies = total * 100 ; //most probably won't.

If you want to try being a Real Programmer, using logic and experiment,
figure out why.

Catch and fix any rounding errors. Half of any programming assignment
is testing it.

==========
PSEUDOCODE: Assignment: DISBURSEMENT
Convert a total in USD into US coins (minimum number of coins.)

//START RUN
//INPUT total (a cash amount)
//CALCULATE total in pennies, handle truncation (multiply by 100)
//STORE total pennies in "total"
//CALCULATE total whole quarters in total
//STORE total quarters in "quarters"
//CALCULATE total = total minus "quarters" * 25
//STORE total
//CALCULATE total whole dimes in "total"
//STORE total dimes in "dimes"
//CALCULATE total = total minus "dimes" * 10
//STORE total
//CALCULATE whole nickels in "total"
//STORE total nickels in "nickels"
//CALCULATE total = total minus "nickels" * 5
//STORE total
//STORE total in "pennies"
//OUTPUT "quarters", "dimes", "nickels", "pennies"
//END RUN

Think it over, and discuss.

==========
SAMPLE RUN:

Enter a cash amount (in cents):total: 1234.56
Quarters: 4938
Dimes: 0
Nickels: 1
Pennies: 1
Topic archived. No new replies allowed.