Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- using namespace std;
- int main()
- {
- int product, quantity;
- float total = 0, price;
- cout << "Enter product number and quantity sold (0 to stop): ";
- cin >> product;
- if (product == 0)
- return 0;
- cin >> quantity;
- while (true)
- {
- switch (product)
- {
- case 1:
- price = 2.98;
- break;
- case 2:
- price = 4.50;
- break;
- case 3:
- price = 9.98;
- break;
- case 4:
- price = 4.49;
- break;
- case 5:
- price = 6.87;
- break;
- default:
- cout << "Invalid product number" << endl;;
- price = 0;
- }
- total = total + (price*quantity);
- cout << "Enter product number and quantity sold (0 to stop): ";
- cin >> product;
- if (product == 0)
- break;
- cin >> quantity;
- }
- cout << "Total price: " << total << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement