Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- cout << "--Welcome to ICS Simple Cashier--";
- cout << "\n\nPlease enter an 'a' fro apples or an 'o' for oranges: ";
- char fruit = '\0'; //what fruit
- float price = 0.f; //said fruit price
- string item = ""; // string for each fruit called item
- cin >> fruit;
- cin.ignore(1000, '\n');
- if (fruit == 'a') //if user wants apples
- {
- price = 0.50f; //price of apples
- item = "Apples";
- {
- cout << "\nHow many apples do you wish to buy: "; //ask user how many he/she wants
- int numA = 0; //number of fruit
- cin >> numA;
- cout << "\nYou want to buy " << numA << " apple(s).";
- {
- if (numA < 1 || numA > 20) //error correction range from 1 to 20
- cout << "Please enter a valid # of apples between 1 and 20.";
- {
- cout << "\n\nItem Qty Price Total"; //output cashier screen thing
- cout << "\n--------------------------------";
- cout << setprecision(2) << fixed << "\nApples " << numA << " $" << price << " $" << numA * price;
- cout << "\nTax(15%): $" << numA * price * 0.15f << "\n";
- cout << "Total Cost: $" << numA * price * 1.15f;
- {
- cout << "\n\nHow much money are you buying with? ";
- int money = 0;
- cin >> money;
- cin.ignore();
- if (money >= numA*price*1.15f && money <= 100)
- {
- cout << "\n-----------------";
- cout << "\nAmount Tendered: $" << money;
- cout << "\nChange: $" << money - numA*price*1.15f;
- }
- else if (money > 100)
- {
- cout << "\nSorry, there is not enough change in the till for that amount";
- return 0;
- }
- else (money < 0.575);
- {
- cout << "\nSorry, that is not enough for your purchase.";
- return 0;
- }
- }
- }
- }
- }
- }
- else if (fruit == 'o')
- {
- price = 0.75f;
- item = "Oranges";
- }
- else
- {
- cout << "\n\nYou did not type in a valid fruit";
- return 0;
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement