C++ Programming Help!

Please build this program for me so I can dissect it and study each line!

Write a C++ program to calculate the fewest number of each denomination needed to pay a bill of amount TOTAL. For example, if the end user enters $97 for TOTAL, program will output that the bills would consist of one $50 bill, two $20 bills, one $5 bill, and two $1 bills. (Assume that the amount is in whole dollars, no cents, and only $100, $50, $20, $10, $5, and $1 denominations are available.) Aid: You may want to use the modulus operator %.
There is unfinished programm operating with Harry Potter world currency. You should be able to easily finish it and adapt to your needs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>

int main()
{
    const int KnutsInGalleon = 493;
    const int KnutsInSickle = 29;

    std::cout << "Enter cost of item in knuts: ";
    int total;
    std::cin >> total;

    int GalleonsTotal = total / KnutsInGalleon; //Integer division!
    total %= KnutsInGalleon;

    int SicklesTotal;/*...
    ...Write this part yourself
    */

    int KnutsTotal = total;

    std::cout << "That would be " << GalleonsTotal << " Galleons, " <<
                 SicklesTotal << " Sickles and " << KnutsTotal <<
                 " Knuts" << std::endl;

    return 0;
}
Last edited on
Topic archived. No new replies allowed.