Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdlib.h>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8. int product, quantity;
  9. float total = 0, price;
  10.  
  11.  
  12. cout << "Enter product number and quantity sold (0 to stop): ";
  13. cin >> product;
  14.  
  15.  
  16. if (product == 0)
  17. return 0;
  18. cin >> quantity;
  19.  
  20.  
  21. while (true)
  22. {
  23. switch (product)
  24. {
  25. case 1:
  26. price = 2.98;
  27. break;
  28. case 2:
  29. price = 4.50;
  30. break;
  31. case 3:
  32. price = 9.98;
  33. break;
  34. case 4:
  35. price = 4.49;
  36. break;
  37. case 5:
  38. price = 6.87;
  39. break;
  40. default:
  41. cout << "Invalid product number" << endl;;
  42. price = 0;
  43. }
  44.  
  45.  
  46. total = total + (price*quantity);
  47. cout << "Enter product number and quantity sold (0 to stop): ";
  48. cin >> product;
  49. if (product == 0)
  50. break;
  51. cin >> quantity;
  52. }
  53. cout << "Total price: " << total << endl;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement