c++ (visual studio)
A mail order house sells five different products whose product numbers and retail prices are:
product 1 - $2.98, product 2 - $4.50, product 3 - $9.98, product 4 - $4.49, product 5 - $6.87.
i) product number
ii) quantity of that product sold
NOTE:
########
Input to the program is product id and price which is seprated by a space. To end the program enter ctlr+D which is EOF
//######################## PGM START ##############################
#include<iostream>
using namespace std;
int main(){
double product[5]={0};
int id;
double qty=0.0,total=0.0;
//request id and quqntity of product from users
cout<<"Enter product id and quantity (ctrl+D to
exit): ";
//read id and quantity untill user enter EOF(ie
ctrl+d)
while(cin>>id>>qty){
switch(id){
case 1:
product[0]+=(qty*2.98);
break;
case 2:
product[1]+=(qty*4.50);
break;
case 3:
product[2]+=(qty*9.98);
break;
case 4:
product[3]+=(qty*4.49);
break;
case 5:
product[4]+=(qty*6.87);
break;
default:
cout<<"Wrong product id!!!!\n";
break;
}
}
//print each product retail price
for(int i=0;i<5;i++){
cout<<"Product
"<<(i+1)<<": $"<<product[i]<<"\n";
//finding the total retail
price
total+=product[i];
}
//printin the total retail price
cout<<"\n\tTotal retail price:
$"<<total<<"\n";
return 0;
}
//###################### PGM END #######################################
OUTPUT
#########

c++ (visual studio) A mail order house sells five different products whose product numbers and retail...