Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- void getSandwich(double &SANDWICH, double &subtotal, int &numberItems, string &topping1, string &sandwich1);
- void getToppings(string &topping1);
- void getSide(double &SIDE, double &subtotal, int &numberItems, string &sideItem);
- void getDrink(double &DRINK, double &subtotal, int &numberItems, string &drink);
- int main ()
- {
- string name, topping1, sandwich1, sandwich2, orderstring, drink, sideItem;
- double subtotal = 0.0, tax = 0.0, total = 0.0, SIDE = 1.25, DRINK = 0.85, SANDWICH = 4.00;
- int numberItems = 0;
- const double SALES_TAX = 0.07;
- cout << "Enter your name: " << endl;
- cin >> name;
- getSandwich(SANDWICH, subtotal, numberItems, topping1, sandwich1);
- getSandwich(SANDWICH, subtotal, numberItems, topping1, sandwich1);
- getSide(SIDE, subtotal, numberItems, sideItem);
- getDrink(DRINK, subtotal, numberItems, drink);
- orderstring = "Sandwich: " + sandwich1 + "\n " + "Topping: " + topping1 + "\n" + "Sandwich: " + sandwich2 + "\n " + "Topping: " + topping1 + "\n" + "Side: " + sideItem + "\n" + "Drink: " + drink;
- system("cls");
- cout << orderstring << endl;
- cout << "Number of Items: " << numberItems << endl;
- cout << "Subtotal: $" << setprecision(2) << fixed << subtotal << endl;
- tax = subtotal * SALES_TAX;
- cout << setprecision(2) << fixed << "Tax: $" << tax << endl;
- total = subtotal + tax;
- cout << "Total: $" << setprecision(2) << fixed << total << endl;
- cout << "Thank you, " << name << "!" << endl;
- system("pause");
- return 0;
- }
- void getSandwich(double &SANDWICH, double &subtotal, int &numberItems, string &topping1, string &sandwich1, string &sandwich2)
- {
- cout << "Sandwich: " << endl;
- cin >> sandwich1;
- cin >> sandwich2;
- subtotal = subtotal + SANDWICH;
- numberItems++;
- getToppings(topping1);
- }
- void getToppings(string &topping1)
- {
- cout << "Topping on Sandwich: " << endl;
- cin >> topping1;
- }
- void getSide(double &SIDE, double &subtotal, int &numberItems, string &sideItem)
- {
- cout << "Side Item: " << endl;
- cin >> sideItem;
- subtotal = subtotal + SIDE;
- numberItems++;
- }
- void getDrink(double &DRINK, double &subtotal, int &numberItems, string &drink)
- {
- cout << "Drink: " << endl;
- cin >> drink;
- subtotal = subtotal + DRINK;
- numberItems++;
- }
Add Comment
Please, Sign In to add comment