Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Cashier.cpp
- 17 Jul 2018
- David Evans
- */
- #include <iostream>
- using namespace std;
- int main() {
- double cost, amountGiven, change;
- cout << "Enter The Cost Of Items Here: £";
- cin >> cost;
- cout << "Enter The Total Money Received From Customer: £";
- cin >> amountGiven;
- if (cost > amountGiven) {
- cout
- << "This Customer Has Not Provided Enough Money To Pay This Transaction"
- << endl;
- } else if (amountGiven == cost) {
- cout << "No Change Is Needed" << endl;
- } else {
- change = amountGiven - cost;
- cout << change << endl;
- int pound = change;
- int coins = (change * 100) - (pound * 100);
- cout << endl << "The Change Is: £" << pound << "." << coins << endl
- << endl;
- cout << "Pounds: £" << pound << endl;
- cout << "Change: " << coins << "p" << endl << endl;
- int twenty = pound / 20;
- if (twenty > 0) {
- cout << "Twenty Pound Notes: " << twenty << endl;
- }
- int ten = pound % 20 / 10;
- if (ten > 0) {
- cout << "Ten Pound Notes: " << ten << endl;
- }
- int five = pound % 20 % 10 / 5;
- if (five > 0) {
- cout << "Five Pound Notes: " << five << endl;
- }
- int two = pound % 20 % 10 % 5 / 2;
- if (two > 0) {
- cout << "Two Pound Coins: " << two << endl;
- }
- int one = pound % 20 % 10 % 5 % 2;
- if (one > 0) {
- cout << "One Pound Coins: " << one << endl;
- }
- int fiftyPence = coins / 50;
- if (fiftyPence > 0) {
- cout << "Fifty Pence Coins: " << fiftyPence << endl;
- }
- int twentyPence = coins % 50 / 20;
- if (twentyPence > 0) {
- cout << "Twenty Pence Coins: " << twentyPence << endl;
- }
- int tenPence = coins % 50 % 20 / 10;
- if (tenPence > 0) {
- cout << "Ten Pence Coins: " << tenPence << endl;
- }
- int fivePence = coins % 50 % 20 % 10 / 5;
- if (fivePence > 0) {
- cout << "Five Pence Coins: " << fivePence << endl;
- }
- int twoPence = coins % 50 % 20 % 10 % 5 / 2;
- if (twoPence > 0) {
- cout << "Two Pence Coins: " << twoPence << endl;
- }
- int onePence = coins % 50 % 20 % 10 % 5 % 2;
- if (onePence > 0) {
- cout << "One Pence Coins: " << onePence << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement