Question 5.17
unknown
c_cpp
a year ago
866 B
0
Indexable
Never
#include <iostream> int main() { int quantity; int productNumber; double revenue = 0; while(true){ std::cout<<"Please enter the product number(Enter -1 to exit)"<< std::endl; std::cin>>productNumber; if(productNumber == -1){ break; } std::cout<<"Please enter the quantity sold"<< std::endl; std::cin>>quantity; switch(productNumber){ case 1: revenue+= (2.98 * quantity); break; case 2: revenue+= (4.50 * quantity); break; case 3: revenue+= (9.98 * quantity); break; case 4: revenue+= (4.49 * quantity); break; case 5: revenue+= (6.87 * quantity); break; } std::cout << "Total revenue generated is: $" << revenue << std::endl; } }