A. product number
B. quantity sold
Your program should use a switch statement to determine the retail price for each product. It should calculate and display the total retail value of all products sold. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.
Code:
#include<iostream>
using namespace std;
int main(){
int number,quantity=0;
int quantity1=0,quantity2=0,quantity3=0,quantity4=0,quantity5=0;
double amount1=.0, amount2=.0,amount3=.0,amount4=.0,amount5=.0;
using namespace std;
int main(){
int number,quantity=0;
int quantity1=0,quantity2=0,quantity3=0,quantity4=0,quantity5=0;
double amount1=.0, amount2=.0,amount3=.0,amount4=.0,amount5=.0;
cout<<" Enter the Product and quantity sold"<<endl;
cin>>number;
cin>>quantity;
switch(number){
case 1:
quantity1=quantity;
amount1=quantity*2.98;
break;
case 2:
quantity2=quantity;
amount2=quantity*4.58;
break;
case 3:
quantity3=quantity;
amount3=quantity*9.98;
break;
case 4:
quantity4=quantity;
amount4=quantity*4.49;
case 5:
quantity5=quantity;
amount5=quantity*6.87;
break;
default:
cout<<" Enter the correct product number "<<endl;
}
cout<<" Sold prod no "<<quantity1+quantity2+quantity3+quantity4+quantity5<<endl;
cout<<" Product value "<<amount1+amount2+amount3+amount4+amount5<<endl;
return 0;
}
cin>>number;
cin>>quantity;
switch(number){
case 1:
quantity1=quantity;
amount1=quantity*2.98;
break;
case 2:
quantity2=quantity;
amount2=quantity*4.58;
break;
case 3:
quantity3=quantity;
amount3=quantity*9.98;
break;
case 4:
quantity4=quantity;
amount4=quantity*4.49;
case 5:
quantity5=quantity;
amount5=quantity*6.87;
break;
default:
cout<<" Enter the correct product number "<<endl;
}
cout<<" Sold prod no "<<quantity1+quantity2+quantity3+quantity4+quantity5<<endl;
cout<<" Product value "<<amount1+amount2+amount3+amount4+amount5<<endl;
return 0;
}