Advertisement
Guest User

Untitled

a guest
Mar 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // michael freeland 5.17
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. int change = 0;
  8. long double total{ 0 };
  9. int count{ 0 };
  10. int loop{ 0 };
  11.  
  12. float total = 0;
  13. while (loop != 2)
  14.  
  15. {
  16. cout << "Chose 1 through 5 to select the product you want." << endl;
  17. cout << "To stop selecting products select 0" << endl;
  18.  
  19. cin >> change;
  20.  
  21.  
  22.  
  23. switch (change) {
  24.  
  25. case 1:
  26. total += total + 2.98f;
  27. count++;
  28. break;
  29.  
  30. case 2:
  31. total += total + 4.50f;
  32. count++;
  33. break;
  34.  
  35. case 3:
  36. total = total + 9.98f;
  37. count++;
  38. break;
  39.  
  40. case 4:
  41. total = total + 4.49f;
  42. count++;
  43. break;
  44.  
  45. case 5:
  46. total = total + 6.87f;
  47. count++;
  48. break;
  49.  
  50. default:
  51. cout << "you did not select a valid product." << endl;
  52.  
  53.  
  54. }
  55.  
  56. cout << "Current total: $" << total << endl;
  57. cout << "Total Items: " << count << endl;
  58.  
  59. cout << "To add more products press 1" << endl;
  60. cout << "To stop shopping press 2" << endl;
  61. cin >> loop;
  62. }
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement