By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,640 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

please change this c++ code into pseudo code..help me please...

P: 1
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
float totalPrice(float ,char,float);
float discPrice(int,char);
void reservation(int row, int col);
char seats[11][5]={
{' ','1','2','3','4'},
{'A','-','-','-','-'},
{'B','-','-','-','-'},
{'C','-','-','-','-'},
{'D','-','-','-','-'},
{'E','-','-','-','-'},
{'F','-','-','-','-'},
{'G','-','-','-','-'},
{'H','-','-','-','-'},
{'I','-','-','-','-'},
{'J','-','-','-','-'},
};

void displayMenu();
struct customerType
{
char firstname[60];
char lastname[60];
int phone;
char c_loc[20];
int reservation_no;
char dest[20];
};
struct menuTrain
{
char food[10];
char ro;
int start;

}menu;

int main()
{
menuTrain menu;
customerType customer;
char ch, back, ro,place;
float discount,total;
int row,num,start,tprice,choice,menu_choice, choose,x;
char l_destination[1][5]={"ARAU"};
char i_destination[10][20]={"A)ALOR SETAR","B)BUTTERWORTH","C)TANJUNG MALIM","D)KL CENTRAL","E)TAMPIN","F)GEMAS" };

ofstream OutFile;
OutFile.open("ticket.txt");

displayMenu();
cout<<endl;
cin>>menu_choice;

while(menu_choice!=3)
{
int count=0;

if(menu_choice == 1)
{
cout<<"FOLLOWING ARE THE TRAIN AVAILABLE :"<<endl;
for(int i=0;i<1;i++)
for(int j=0;j<6;j++)
cout<<"TRAIN FROM "<<l_destination[i]<<" TO "<<i_destination[j]<<endl;

}

if(menu_choice == 2)
{
cout<<setw(40)<<"\n\n ::Please enter the required information for passenger number::"<<endl;
cout<<"\n\n\nEnter your first name: ";
cin>>ws;
cin.getline(customer.firstname,60);
cout<<endl;
cout<<"Enter your last name: ";
cin>>ws;
cin.getline(customer.lastname,60);
cout<<endl;
cout<<"Enter your phone number: ";
cin>>customer.phone;
cout<<endl;
cout<<"Enter the Reservation No. of Ticket"<<endl;
cin>>ws;
cin>>(customer.reservation_no);
cout<<endl;
cout<<"Enter the current location (IN CAPITAL LETTERS ONLY): ";
cin>>ws;
cin.getline(customer.c_loc,20);
cout<<endl;
cout<<"Enter the destination you want to go(ALPAHABET ONLY): ";
cin>>ws;
cin>>place;
cout<<endl;
cout<<"To be more detail,would you input the destination(IN CAPITAL LETTERS ONLY): ";
cin>>ws;
cin.getline(customer.dest,20);
cout<<endl<<endl;
}
if(menu_choice==3)
{
displayMenu();
cout<<endl;
cin>>menu_choice;
}



cout<<"To exit Press 3"<<endl;
cin>>menu_choice;

count++;
}

cout<<"\n\n\n\n\n\n";

cout<<setw(60)<<"********************************* ****"<<endl;
cout<<setw(60)<<"* ON WHICH TIME YOU WANT TO DEPART *"<<endl;
cout<<setw(60)<<"* 11 AM *"<<endl;
cout<<setw(60)<<"* 10 AM *"<<endl;
cout<<setw(60)<<"* 9 AM *"<<endl;
cout<<setw(60)<<"********************************* ****"<<endl<<endl<<endl<<endl;

cout<<"Input the time you want to depart : ";
cin>>choose;
cout<<endl<<endl;

cout<<"In which class you want to take?"<<endl;
cout<<"Make your choice"<<endl<<endl;
cout<<"\n\n\n\n\n\n";

cout<<setw(60)<<"********************************* ****"<<endl;
cout<<setw(60)<<"* (M)Premium *"<<endl;
cout<<setw(60)<<"* (P)Platinium *"<<endl;
cout<<setw(60)<<"* (G)Gold *"<<endl;
cout<<setw(60)<<"********************************* ****"<<endl<<endl<<endl<<endl;

cout<<"Enter your choice(ALPHABET ONLY)"<<endl;
cin>>ch;
cout<<endl<<endl;

while(choice!=4)
{
char ro;
int row,start;
cout << endl << "Menu:\n\n\n";
cout << "1) Choose Seat\n\n";
cout << "2) Price\n\n";
cout << "3) Food\n\n";
cout << "4) Exit\n\n";
cout << "Enter your choice : ";
cin >> choice;
cout << endl;

if (choice == 1)
{
reservation(row,start);
cout<<"In which row you want seat?(CAPITAL LETTER ONLY) ";
cin>>menu.ro;
cout<<"In which column you want seat? ";
cin>>menu.start;
if(menu.ro=='A')
{row=1;}

else if(menu.ro=='B')
{row=2;}

else if(menu.ro=='C')
{row=3;}

else if(menu.ro=='D')
{row=4;}

else if(menu.ro=='E')
{row=5;}

else if(menu.ro=='F')
{row=6;}

else if(menu.ro=='G')
{row=7;}

else if(menu.ro=='H')
{row=8;}

else if(menu.ro=='I')
{row=9;}

else if(menu.ro=='J')
{row=10;}

cout<<endl;
cout<<"Your seat is reserved";

}

else if(choice == 2)
{
int age,price;
float discount;
char type;

cout << "How old are you? :";
cin >> age;

if (age>= 70 )
price=40;

else if (age>18)
price = 80;

else
price =20;

discount= discPrice(price,ch);
total= totalPrice(tprice,place,discount);

cout << "Total price is : RM " <<price<<endl;
cout<<"Total price after discount is RM "<<discount<<endl;
cout<<"Total price you need to pay is RM "<<total<<endl;
}

else if(choice == 3)
{
cout<<"Enter your food choice (Sandwich/Kaya bun/Biscuits):"<<endl;
cin>>ws;
cin.getline(menu.food, 10);
}

else if(choice == 4)
{
break;
}
}

OutFile<<setw(40)<<"Your E-Ticket is :"<<endl;
OutFile<<"________________________________________ __________________________________________________ ________"<<endl;
OutFile<<" "<<endl;
OutFile<<" ETS TRAIN TICKET "<<endl;
OutFile<<"-------------------------------------------------------------------------------------------------"<<endl;
OutFile<<"Reservation No. : "<<customer.reservation_no<<endl;
OutFile<<"________________________________________ __________________________________________________ _______"<<endl;
OutFile<<"Passenger Information : "<<endl;
OutFile<<"Name : "<<customer.firstname<<" "<<customer.lastname<<" "<<endl;
OutFile<<" "<<endl;
OutFile<<"Phone No. : 0"<<customer.phone<<" "<<endl;
OutFile<<"________________________________________ __________________________________________________ _______"<<endl;
OutFile<<"Depart : "<<customer.c_loc<<" "<<endl;
OutFile<<"Arrive : "<<customer.dest<<" "<<endl;
OutFile<<"Time Depart : "<<choose<<" AM "<<endl;
OutFile<<"________________________________________ __________________________________________________ _______"<<endl;
OutFile<<"Ticket Information : "<<endl;
OutFile<<"Status: "<<ch<<" "<<endl;
OutFile<<"Seat : "<<menu.ro<<menu.start<<" "<<endl;
OutFile<<"Food : "<<menu.food<<" "<<endl;
OutFile<<"Total Price : RM "<<total<<" "<<endl;
OutFile<<" "<<endl;
OutFile<<"________________________________________ __________________________________________________ _______"<<endl;
OutFile.close();

}
void displayMenu()
{
cout<< "* * * * * * * * * * * * * * * * * * * * * * * * * * * **** ***** **** " <<endl;
cout<< " * * * * * * ********* * * * * * * * * * * * * * * * * * " <<endl;
cout<< " * * * * * * * * * * * * *** * ** " <<endl;
cout<< " * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" <<endl;
cout<< " * * * * **** * **** " <<endl;
cout<< " ********* *" <<endl;
cout<< "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *" <<endl<<endl<<endl<<endl<<endl;
cout<<" WELCOME TO OUR PEOS(PROMOTION ETS ONLINE SYSTEM)";
cout<<"\n\n\n\n";
cout<<setw(60)<<"********************************* ****"<<endl;
cout<<setw(60)<<"* ETS TRAIN RESERVATION *"<<endl;
cout<<setw(60)<<"* MAIN MENU *"<<endl;
cout<<setw(60)<<"* ENTER YOUR CHOICE *"<<endl;
cout<<setw(60)<<"* PRESS 1 FOR SEARCH OF TRAIN *"<<endl;
cout<<setw(60)<<"* PRESS 2 FOR BOOKING *"<<endl;
cout<<setw(60)<<"* NOW ENTER YOUR CHOICE: *"<<endl;
cout<<setw(60)<<"********************************* ****"<<endl;
}

void reservation(int row,int col)
{
for (int r=0;r<11;r++)
{
for(int col=0;col<5;col++)
{
cout << seats[r][col]<<" ";
}
cout << endl << endl;
}
}

float discPrice(int price,char ch)
{
float nprice;
char i;

if (ch=='G')
nprice=0.5*price;

else if(ch=='P')
nprice=0.3*price;

else if(ch=='M')
nprice=0.2*price;

return nprice;
}

float totalPrice(float tprice,char place,float discount)
{

if (place=='A')
tprice=1*discount;

else if (place=='B')
tprice=2*discount;

else if(place=='C')
tprice=3*discount;

else if(place=='D')
tprice=4*discount;

else if(place=='E')
tprice=5*discount;

else if(place=='F')
tprice=6*discount;

return tprice;
}
Mar 13 '17 #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,197
What do you understand pseudo code to be? Maybe provide a small example.
Mar 13 '17 #2

Post your reply

Sign in to post your reply or Sign up for a free account.