Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string szGood;
- int szChoice;
- float szPrice, szTotalPrice, szDiscount, szQuantity;
- cout << "Enter your good: ";
- getline(cin, szGood);
- cout << "Enter the price of your good: ";
- cin >> szPrice;
- cout << "Enter quantity of your good: ";
- cin >> szQuantity;
- for (int x = 1; x > 0;)
- {
- cout << "Did you get discout? Else enter 0: ";
- cin >> szDiscount;
- cout << endl;
- if (szDiscount > 100)
- {
- cout << "You cannot get more than 100% discount, try again." << endl << endl;
- }
- else
- {
- break;
- }
- }
- cout << "Your good: " << szGood << endl;
- cout << "Price: " << szPrice << endl;
- cout << "Quantity: " << szQuantity << endl;
- cout << "Discount: " << szDiscount << "%" << endl << endl;
- //Matematiken
- if (szDiscount == 0)
- {
- szTotalPrice = szPrice * szQuantity;
- }
- else
- {
- szDiscount = szPrice * szQuantity * szDiscount / 100;
- szTotalPrice = szPrice * szQuantity - szDiscount;
- }
- cout << "Total cost: " << szTotalPrice << endl << endl;
- for (int y = 1; y > 0;)
- {
- cout << "Have you got more goods you'd like a price check on?" << endl << endl;
- cout << "1 = Yes" << endl;
- cout << "2 = No, quit program." << endl << endl;
- cout << "Choice: ";
- cin >> szChoice;
- if (szChoice == 1 || szChoice == 2)
- {
- if (szChoice == 1)
- {
- cout << endl;
- return main();
- }
- else
- {
- return 0;
- }
- }
- else
- {
- cout << "You must enter 1 or 2, please try again." << endl << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement