Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int change();
- int main()
- {
- change();
- return 0;
- }
- int change()
- {
- const int five_dollars = 500;
- const int one_dollar = 100;
- const int fifty_cent = 50;
- const int twentyfive_cent = 25;
- const int ten_cents = 10;
- const int five_cents = 5;
- const int penny = 1;
- int your_change;
- char yes_no;
- int i;
- your_change = 0;
- for (i = 0; i < 10; i++)
- {
- cout << "Enter your change in cents: ";
- cin >> your_change;
- cout << endl;
- cout << "The change you entered is: " << your_change << endl;
- cout <<"If that is the correct change you wish to use please click 'y' \n";
- cout << "Else click 'n' to re-put your change again\n";
- cin >> yes_no;
- cout << endl << endl;
- if( yes_no == 'n' || yes_no == 'N')
- {
- cout << "Re-enter your change in cents again: ";
- cin >> your_change;
- cout << "The change you entered is: " << your_change;
- cout <<"If that is the correct change you wish to use please click 'y' \n";
- cout << "Else click 'n' to re-put your change again\n";
- cin >> yes_no;
- cout << endl << endl;
- }
- else
- if( yes_no == 'y' || yes_no == 'Y')
- {
- cout << "The number in Five-dollars to be returned is: "
- << your_change / five_dollars;
- cout << endl;
- your_change %= five_dollars;
- cout << "The number in One-dollar to be returned is: "
- << your_change / one_dollar;
- cout << endl;
- your_change %= one_dollar;
- cout << "The number in Fifty-cents to be returned is: "
- << your_change / fifty_cent;
- cout << endl;
- your_change %= fifty_cent;
- cout << "The number in Twenty-five cents to be returned is: "
- << your_change / twentyfive_cent;
- cout << endl;
- your_change %= twentyfive_cent;
- cout << "The number in Ten-cents to be returned is: "
- << your_change / ten_cents;
- cout << endl;
- your_change %= ten_cents;
- cout << "The number in Five-cents to be returned is: "
- << your_change / five_cents;
- cout << endl;
- your_change %= five_cents;
- cout << "The number in a Penny to be returned is: "
- << your_change / penny;
- cout << endl;
- your_change %= penny;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement