Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- #include<conio.h>
- #include<iomanip>
- using namespace std;
- int main()
- {
- char code,type[5],from[10],to[10];
- int qty;
- float payment;
- cout<<"Please enter code(A|B)";
- cin>>code;
- cout<<"Please enter the type(AA|AB|BA|BB)";
- cin.getline(type,5);
- cout<<"Please enter the quantity";
- cin>>qty;
- switch(code)
- {
- case 'A':if(strcmp(type,"AA")==0);
- {
- strcpy(from,"Tampin");
- strcpy(to,"S.Alam");
- payment=qty*14.50;
- }
- else if(strcmp(type,"AB")==0);
- {
- strcpy(from,"Melaka");
- strcpy(to,"S.Alam");
- payment=qty*16.50;
- }
- else
- {
- strcpy(from," ");
- strcpy(to," ");
- payment=0;
- }
- break;
- case 'B':if(strcmp(type,"BA")==0);
- {
- strcpy(from,"Penang");
- strcpy(to,"S.Alam");
- payment=qty*30.50;
- }
- else if(strcmp(type,"BB")==0);
- {
- strcpy(from,"Kedah");
- strcpy(to,"S.Alam");
- payment=qty*32.50;
- }
- else
- {
- strcpy(from," ");
- strcpy(to" ");
- payment=0;
- }
- break;
- default :strcpy(from," ");
- strcpy(to," ");
- payment=0;
- }
- cout<<"\tABC BUS";
- cout<<endl<<"Code: "<<code;
- cout<<endl<<"Type: "<<type;
- cout<<endl<<"From: "<<from;
- cout<<endl<<"To: "<<to;
- cout<<endl<<"Quantity: "<<qty;
- cout<<endl<<fixed<<setprecision(2)<<"Payment: "<<payment;
- cout<<endl<<"\tThank you";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement