Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. //requirement #1.
  6. //initial integers.
  7. float depth = 0,
  8. width = 0,
  9. heigth = 0;
  10. float area1 = 0,
  11. area2 = 0,
  12. combined_area = 0;
  13. double total_price = 0;
  14. char compute;
  15. //initial input.
  16. while (true)
  17. {
  18. cout << "=====================" << endl;
  19. cout << "GLASS SHOWER ESTIMATE" << endl;
  20. cout << "=====================" << endl;
  21.  
  22. //enter the depth, width, heigth.
  23. cout << "Depth: ";
  24. cin >> depth;
  25. cout << "Width: ";
  26. cin >> width;
  27. cout << "Heigth: ";
  28. cin >> heigth;
  29. //measure the areas.
  30.  
  31. area1 = depth * heigth;
  32. area2 = width * heigth;
  33. combined_area = area1 + area2;
  34. //requirement #2.
  35. float price_unit;
  36. if (combined_area >= 6000)
  37. {
  38. price_unit = .99;
  39. cout << "Unit Price: " << price_unit << endl;
  40. total_price += price_unit * combined_area;
  41. //cout<<combined_area;
  42. }
  43. else if (combined_area >= 3000)
  44. {
  45. price_unit = 1.29;
  46. cout << "Unit Price: " << price_unit << endl;
  47. total_price += price_unit * combined_area;
  48. //cout<<combined_area;
  49. }
  50. else
  51. {
  52. price_unit = 1.49;
  53. cout << "Unit Price: " << price_unit << endl;
  54. total_price += price_unit * combined_area;
  55. }
  56.  
  57. //requirement #3.
  58. //thickness of glass.
  59. float thickness;
  60. float surcharge;
  61. cout << "Thickness: ";
  62. cin >> thickness;
  63. if (thickness >= .5)
  64. {
  65. surcharge = .5;
  66. //checking the surcharge.
  67. cout << surcharge * 100 << "%" << " for " << surcharge << " thickness." << endl;
  68. total_price += surcharge * total_price;
  69. }
  70. else if (thickness >= .375)
  71. {
  72. surcharge = .20;
  73. cout << surcharge * 100 << "%" << " for " << surcharge << " thickness." << endl;
  74. total_price += surcharge * total_price;
  75. }
  76.  
  77. //requirement #4.
  78. //using code to find possible discount.
  79. double discount_code;
  80. float discount;
  81. cout << "Discount Code (enter 0 if no code): ";
  82. cin >> discount_code;
  83. if (discount_code == 112233)
  84. {
  85. discount = .20 * total_price;
  86. //checking discount given.
  87. cout << "20% Discount applied." << endl;
  88. total_price = total_price - discount;
  89. }
  90. else if (discount_code == 111222)
  91. {
  92. discount = .10 * total_price;
  93. cout << "10% Discount applied." << endl;
  94. total_price = total_price - discount;
  95. }
  96. else if (discount_code == 0)
  97. {
  98. cout << "There's no discount" << endl;
  99. //gotta recheck this output.
  100. }
  101. else
  102. {
  103. cout << "Invalid Discount Code!" << endl;
  104. }
  105. //requirement #5.
  106. //output will be shown
  107. //and the program will ask the user if he wants to
  108. //add another number.
  109. cout << "The installed price is $ " << total_price << endl;
  110. cout << "Would you like to compute another one? (y/n)";
  111. cin >> compute;
  112. if (compute == 'y' || compute == 'Y')
  113. {
  114. depth = 0,
  115. width = 0,
  116. heigth = 0;
  117. area1 = 0,
  118. area2 = 0,
  119. combined_area = 0;
  120. total_price = 0;
  121. cout << " " << endl;
  122. }
  123. else
  124. {
  125. break;
  126. }
  127. }
  128. system("PAUSE");
  129. return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement