Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include<iostream>
  2. #include<string.h>
  3. #include<conio.h>
  4. #include<iomanip>
  5.  
  6. using namespace std;
  7. int main()
  8. {
  9.     char code,type[5],from[10],to[10];
  10.     int qty;
  11.     float payment;
  12.    
  13.     cout<<"Please enter code(A|B)";
  14.     cin>>code;
  15.    
  16.     cout<<"Please enter the type(AA|AB|BA|BB)";
  17.     cin.getline(type,5);
  18.    
  19.     cout<<"Please enter the quantity";
  20.     cin>>qty;
  21.    
  22.     switch(code)
  23.     {
  24.         case 'A':if(strcmp(type,"AA")==0);
  25.                  {
  26.                     strcpy(from,"Tampin");
  27.                     strcpy(to,"S.Alam");
  28.                     payment=qty*14.50;
  29.                  }
  30.                  else if(strcmp(type,"AB")==0);
  31.                  {
  32.                     strcpy(from,"Melaka");
  33.                     strcpy(to,"S.Alam");
  34.                     payment=qty*16.50;
  35.                  }
  36.                  else
  37.                  {
  38.                     strcpy(from," ");
  39.                     strcpy(to," ");
  40.                     payment=0;
  41.                  }
  42.                  
  43.                  break;
  44.                  
  45.         case 'B':if(strcmp(type,"BA")==0);
  46.                  {
  47.                     strcpy(from,"Penang");
  48.                     strcpy(to,"S.Alam");
  49.                     payment=qty*30.50;
  50.                  }
  51.                  else if(strcmp(type,"BB")==0);
  52.                  {
  53.                     strcpy(from,"Kedah");
  54.                     strcpy(to,"S.Alam");
  55.                     payment=qty*32.50;
  56.                  }
  57.                  else
  58.                  {
  59.                     strcpy(from," ");
  60.                     strcpy(to" ");
  61.                     payment=0;
  62.                  }
  63.                  
  64.                  break;
  65.                  
  66.         default :strcpy(from," ");
  67.                  strcpy(to," ");
  68.                  payment=0;
  69.     }
  70.    
  71.     cout<<"\tABC BUS";
  72.     cout<<endl<<"Code: "<<code;
  73.     cout<<endl<<"Type: "<<type;
  74.     cout<<endl<<"From: "<<from;
  75.     cout<<endl<<"To: "<<to;
  76.     cout<<endl<<"Quantity: "<<qty;
  77.     cout<<endl<<fixed<<setprecision(2)<<"Payment: "<<payment;
  78.     cout<<endl<<"\tThank you";
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement