Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int change();
  6.  
  7. int main()
  8. {
  9.  change();
  10.  return 0;
  11. }
  12.  
  13. int change()
  14. {
  15.  const int five_dollars = 500;
  16.  const int one_dollar = 100;
  17.  const int fifty_cent = 50;
  18.  const int twentyfive_cent = 25;
  19.  const int ten_cents = 10;
  20.  const int five_cents = 5;
  21.  const int penny = 1;
  22.  
  23.   int your_change;
  24.   char yes_no;
  25.   int i;
  26.  your_change = 0;
  27.  
  28.   for (i = 0; i < 10; i++)
  29.   {
  30.   cout << "Enter your change in cents: ";
  31.   cin >> your_change;
  32.   cout << endl;
  33.  
  34.   cout << "The change you entered is: " << your_change << endl;
  35.   cout <<"If that is the correct change you wish to use please click 'y' \n";
  36.   cout << "Else click 'n' to re-put your change again\n";
  37.   cin >> yes_no;
  38.  cout << endl << endl;
  39.  
  40.   if( yes_no == 'n' || yes_no == 'N')
  41.   {
  42.    cout << "Re-enter your change in cents again: ";
  43.    cin >> your_change;
  44.   cout << "The change you entered is: " << your_change;
  45.   cout <<"If that is the correct change you wish to use please click 'y' \n";
  46.   cout << "Else click 'n' to re-put your change again\n";
  47.    cin >> yes_no;
  48.   cout << endl << endl;
  49.   }
  50.   else
  51.    if( yes_no == 'y' || yes_no == 'Y')
  52.    {
  53.     cout << "The number in Five-dollars to be returned is: "
  54.     << your_change / five_dollars;
  55.     cout << endl;
  56.     your_change %= five_dollars;
  57.  
  58.     cout << "The number in One-dollar to be returned is: "
  59.         << your_change / one_dollar;
  60.     cout << endl;
  61.     your_change %= one_dollar;
  62.  
  63.     cout << "The number in Fifty-cents to be returned is: "
  64.         << your_change / fifty_cent;
  65.     cout << endl;
  66.     your_change %= fifty_cent;
  67.  
  68.     cout << "The number in Twenty-five cents to be returned is: "
  69.         << your_change / twentyfive_cent;
  70.     cout << endl;
  71.     your_change %= twentyfive_cent;
  72.  
  73.     cout << "The number in Ten-cents to be returned is: "
  74.         << your_change / ten_cents;
  75.     cout << endl;
  76.     your_change %= ten_cents;
  77.  
  78.     cout << "The number in Five-cents to be returned is: "
  79.         << your_change / five_cents;
  80.     cout << endl;
  81.     your_change %= five_cents;
  82.  
  83.     cout << "The number in a Penny to be returned is: "
  84.         << your_change / penny;
  85.     cout << endl;
  86.     your_change %= penny;
  87.    }
  88.   }
  89.   return 0;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement