Advertisement
Guest User

Untitled

a guest
Mar 17th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. string szGood;
  9. int szChoice;
  10. float szPrice, szTotalPrice, szDiscount, szQuantity;
  11.  
  12. cout << "Enter your good: ";
  13. getline(cin, szGood);
  14. cout << "Enter the price of your good: ";
  15. cin >> szPrice;
  16. cout << "Enter quantity of your good: ";
  17. cin >> szQuantity;
  18.  
  19. for (int x = 1; x > 0;)
  20. {
  21. cout << "Did you get discout? Else enter 0: ";
  22. cin >> szDiscount;
  23. cout << endl;
  24.  
  25. if (szDiscount > 100)
  26. {
  27. cout << "You cannot get more than 100% discount, try again." << endl << endl;
  28. }
  29. else
  30. {
  31. break;
  32. }
  33. }
  34.  
  35. cout << "Your good: " << szGood << endl;
  36. cout << "Price: " << szPrice << endl;
  37. cout << "Quantity: " << szQuantity << endl;
  38. cout << "Discount: " << szDiscount << "%" << endl << endl;
  39.  
  40. //Matematiken
  41. if (szDiscount == 0)
  42. {
  43. szTotalPrice = szPrice * szQuantity;
  44. }
  45. else
  46. {
  47. szDiscount = szPrice * szQuantity * szDiscount / 100;
  48. szTotalPrice = szPrice * szQuantity - szDiscount;
  49. }
  50.  
  51. cout << "Total cost: " << szTotalPrice << endl << endl;
  52.  
  53. for (int y = 1; y > 0;)
  54. {
  55. cout << "Have you got more goods you'd like a price check on?" << endl << endl;
  56. cout << "1 = Yes" << endl;
  57. cout << "2 = No, quit program." << endl << endl;
  58. cout << "Choice: ";
  59. cin >> szChoice;
  60.  
  61. if (szChoice == 1 || szChoice == 2)
  62. {
  63. if (szChoice == 1)
  64. {
  65. cout << endl;
  66.  
  67. return main();
  68. }
  69. else
  70. {
  71. return 0;
  72. }
  73. }
  74. else
  75. {
  76. cout << "You must enter 1 or 2, please try again." << endl << endl;
  77. }
  78. }
  79.  
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement