Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //std::setprecision()
- #include <iomanip>
- // priceme.cp
- using std::cout;
- using std::cin;
- using std::numeric_limits;
- using std::streamsize;
- using std::setprecision;
- void options();
- void Quantity();
- double get_subtotal(int tm,int tg,int td,
- double mp, double gp,double dp);
- void total_sales(double st);
- void clear_error();
- int main(){
- double
- monitor=159.99,
- getdone=179.99,
- delight=249.99;
- int q=0,option=0,mc=0,mg=0,md=0;
- char run='y';
- while(run=='y'){
- options();
- cin>>option;
- if(!cin){
- clear_error();
- continue;
- }
- switch(option){
- case 1:
- Quantity();
- cin>>q;
- if(!cin){
- clear_error();
- continue;
- }
- mc+=q;
- break;
- case 2:
- Quantity();
- cin>>q;
- if(!cin){
- clear_error();
- continue;
- }
- mg+=q;
- break;
- case 3:
- Quantity();
- cin>>q;
- if(!cin){
- clear_error();
- continue;
- }
- md+=q;
- break;
- case 4:
- run='n';
- break;
- default:
- clear_error();
- break;
- } // end switch
- } // end while
- total_sales(get_subtotal(mc,mg,md,monitor,getdone,delight));
- return 0;
- }
- double get_subtotal(int tm,int tg,int td,
- double mp, double gp,double dp)
- {
- cout<<"\n\n\t\tTOTAL ORDER\n"
- <<tm<<" ICU Monitors @ $"<<(tm*mp)<<"\n"
- <<tg<<" Get'er done mon. @ $"<<(tg*gp)<<"\n"
- <<td<<" Gamer's delight @ $"<<(td*dp)<<"\n"
- <<"\n";
- return ((tm*mp)+(tg*gp)+(td*dp));
- }
- void total_sales(double st)
- {
- cout<<"\nTotal Cost of Monitors: $"
- << st
- <<"\nSales Tax (calculated at 6.5%): $"
- <<setprecision(5)
- <<((st*6.5)/100)
- <<"\nBalance Due: $"
- <<(st+(st*0.065))
- <<"\n";
- }
- void options()
- {
- cout<<"\n\n\t\tMENU \n"
- <<"\n1. ICU Monitor $159.99"
- <<"\n2. Get'er Done! Monitor $179.99"
- <<"\n3. Gamer's Delight Monitor $249.99"
- <<"\n4. Checkout"
- <<"\nEnter the option (1-4): ";
- }
- void Quantity()
- {
- cout<<"Enter quantity.\n";
- }
- void clear_error()
- {
- cout<<"\nInvalid option\n" ;
- cin.clear();
- cin.ignore(
- numeric_limits<streamsize>::max(),
- '\n');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement