#include<iostream.h>
main ()
{
int selection,quantity;
double price;
cout<<"\n 1. Pen =RM 0.50";
cout<<"\n 2. Pensil =RM 0.30";
cout<<"\n 3. Ruler =RM 0.20";
cout<<"\n 4. Erser =RM 0.10"<<endl;
cout<<"\n Enter your selection= ";
cin>>selection;
cout<<"\n Enter your quantity= ";
cin>>quantity;
switch (selection)
{
case 1:
price = quantity * 0.50;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Pen with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
case 2:
price = quantity * 0.30;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Pensil with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
case 3:
price = quantity * 0.20;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Ruler with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
case 4:
price = quantity * 0.10;
cout<<"\n Price = RM "<<price<<endl;
cout<<"\n Your selection is Erser with "<<quantity;
cout<<" ,as your quantity(s)"<<endl;
break;
default:
cout<<"\n Invalid selection"<<endl;
}
return 0;
}
No comments:
Post a Comment