Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. /*
  2.  Cashier.cpp
  3.  17 Jul 2018
  4.  David Evans
  5.  */
  6.  
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. int main() {
  11.     double cost, amountGiven, change;
  12.  
  13.  
  14.     cout << "Enter The Cost Of Items Here: £";
  15.     cin >> cost;
  16.     cout << "Enter The Total Money Received From Customer: £";
  17.     cin >> amountGiven;
  18.  
  19.     if (cost > amountGiven) {
  20.         cout
  21.                 << "This Customer Has Not Provided Enough Money To Pay This Transaction"
  22.                 << endl;
  23.     } else if (amountGiven == cost) {
  24.         cout << "No Change Is Needed" << endl;
  25.     } else {
  26.  
  27.         change = amountGiven - cost;
  28.         cout << change << endl;
  29.         int pound = change;
  30.         int coins = (change * 100) - (pound * 100);
  31.  
  32.         cout << endl << "The Change Is:      £" << pound << "." << coins << endl
  33.                 << endl;
  34.  
  35.  
  36.         cout << "Pounds:             £" << pound << endl;
  37.  
  38.  
  39.         cout << "Change:             " << coins << "p" << endl << endl;
  40.  
  41.         int twenty = pound / 20;
  42.         if (twenty > 0) {
  43.             cout << "Twenty Pound Notes: " << twenty << endl;
  44.         }
  45.  
  46.         int ten = pound % 20 / 10;
  47.         if (ten > 0) {
  48.             cout << "Ten Pound Notes:    " << ten << endl;
  49.         }
  50.  
  51.         int five = pound % 20 % 10 / 5;
  52.         if (five > 0) {
  53.             cout << "Five Pound Notes:   " << five << endl;
  54.         }
  55.  
  56.         int two = pound % 20 % 10 % 5 / 2;
  57.         if (two > 0) {
  58.             cout << "Two Pound Coins:    " << two << endl;
  59.         }
  60.  
  61.         int one = pound % 20 % 10 % 5 % 2;
  62.         if (one > 0) {
  63.             cout << "One Pound Coins:    " << one << endl;
  64.         }
  65.  
  66.         int fiftyPence = coins / 50;
  67.         if (fiftyPence > 0) {
  68.             cout << "Fifty Pence Coins:  " << fiftyPence << endl;
  69.         }
  70.  
  71.         int twentyPence = coins % 50 / 20;
  72.         if (twentyPence > 0) {
  73.             cout << "Twenty Pence Coins: " << twentyPence << endl;
  74.         }
  75.  
  76.         int tenPence = coins % 50 % 20 / 10;
  77.         if (tenPence > 0) {
  78.             cout << "Ten Pence Coins:    " << tenPence << endl;
  79.         }
  80.  
  81.         int fivePence = coins % 50 % 20 % 10 / 5;
  82.         if (fivePence > 0) {
  83.             cout << "Five Pence Coins:   " << fivePence << endl;
  84.         }
  85.  
  86.         int twoPence = coins % 50 % 20 % 10 % 5 / 2;
  87.         if (twoPence > 0) {
  88.             cout << "Two Pence Coins:    " << twoPence << endl;
  89.         }
  90.  
  91.         int onePence = coins % 50 % 20 % 10 % 5 % 2;
  92.         if (onePence > 0) {
  93.             cout << "One Pence Coins:    " << onePence << endl;
  94.         }
  95.     }
  96.  
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement