Advertisement
SonicDesu

Funty

Sep 6th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5. int main() {
  6.     int pence_amount{};
  7.     int rest;
  8.     cout << "Enter amount in pence: ";
  9.     cin >> pence_amount;
  10.     int pounds{ 0 }, half_pounds{ 0 }, twenty_pence{ 0 }, ten_pence{ 0 }, five_pence{ 0 }, two_pence{ 0 }, penny{ 0 };
  11.     if (pence_amount >= 100) {
  12.         pounds = pence_amount / 100;
  13.     }
  14.     rest = pence_amount % 100;
  15.     if (rest >= 50) {
  16.         half_pounds = rest / 50;
  17.         rest = rest % 50;
  18.     }
  19.     if (rest >= 20) {
  20.         twenty_pence = rest / 20;
  21.         rest = rest % 20;
  22.     }
  23.     if (rest >= 10) {
  24.         ten_pence = rest / 10;
  25.         rest = rest % 10;
  26.     }
  27.     if (rest >= 5) {
  28.         five_pence = rest / 5;
  29.         rest = rest % 5;
  30.     }
  31.     if (rest >= 2) {
  32.         two_pence = rest / 2;
  33.         rest = rest % 2;
  34.     }
  35.     penny = rest;
  36.  
  37.  
  38.     cout << endl;
  39.     cout << "You can provide change for this change as follows: " << endl;
  40.     cout << "Pounds: " << pounds << endl;
  41.     cout << "Half Pounds: " << half_pounds << endl;
  42.     cout << "Twenty Pence: " << twenty_pence << endl;
  43.     cout << "Ten Pence: " << ten_pence << endl;
  44.     cout << "Five Pence: " << five_pence << endl;
  45.     cout << "Two Pence: " << two_pence << endl;
  46.     cout << "Pennies: " << penny << endl;
  47.  
  48.  
  49.     system("pause");
  50.     return 0;
  51. }
  52. // 1.Wczytuje ilość w pensach.
  53. // 2.Sprawdzam ile funtów się mieści w nich
  54. // 3.Sprawdzam, czy została reszta
  55. // 4.Jeśli tak, sprawdzam dalej.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement