Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int pence_amount{};
- int rest;
- cout << "Enter amount in pence: ";
- cin >> pence_amount;
- int pounds{ 0 }, half_pounds{ 0 }, twenty_pence{ 0 }, ten_pence{ 0 }, five_pence{ 0 }, two_pence{ 0 }, penny{ 0 };
- if (pence_amount >= 100) {
- pounds = pence_amount / 100;
- }
- rest = pence_amount % 100;
- if (rest >= 50) {
- half_pounds = rest / 50;
- rest = rest % 50;
- }
- if (rest >= 20) {
- twenty_pence = rest / 20;
- rest = rest % 20;
- }
- if (rest >= 10) {
- ten_pence = rest / 10;
- rest = rest % 10;
- }
- if (rest >= 5) {
- five_pence = rest / 5;
- rest = rest % 5;
- }
- if (rest >= 2) {
- two_pence = rest / 2;
- rest = rest % 2;
- }
- penny = rest;
- cout << endl;
- cout << "You can provide change for this change as follows: " << endl;
- cout << "Pounds: " << pounds << endl;
- cout << "Half Pounds: " << half_pounds << endl;
- cout << "Twenty Pence: " << twenty_pence << endl;
- cout << "Ten Pence: " << ten_pence << endl;
- cout << "Five Pence: " << five_pence << endl;
- cout << "Two Pence: " << two_pence << endl;
- cout << "Pennies: " << penny << endl;
- system("pause");
- return 0;
- }
- // 1.Wczytuje ilość w pensach.
- // 2.Sprawdzam ile funtów się mieści w nich
- // 3.Sprawdzam, czy została reszta
- // 4.Jeśli tak, sprawdzam dalej.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement