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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hian
    New Member
    • Mar 2017
    • 1

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

    #include<iostre am>
    #include<iomani p>
    #include<fstrea m>
    using namespace std;
    float totalPrice(floa t ,char,float);
    float discPrice(int,c har);
    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,t price,choice,me nu_choice, choose,x;
    char l_destination[1][5]={"ARAU"};
    char i_destination[10][20]={"A)ALOR SETAR","B)BUTTE RWORTH","C)TANJ UNG MALIM","D)KL CENTRAL","E)TAM PIN","F)GEMAS" };

    ofstream OutFile;
    OutFile.open("t icket.txt");

    displayMenu();
    cout<<endl;
    cin>>menu_choic e;

    while(menu_choi ce!=3)
    {
    int count=0;

    if(menu_choice == 1)
    {
    cout<<"FOLLOWIN G ARE THE TRAIN AVAILABLE :"<<endl;
    for(int i=0;i<1;i++)
    for(int j=0;j<6;j++)
    cout<<"TRAIN FROM "<<l_destinatio n[i]<<" TO "<<i_destinatio n[j]<<endl;

    }

    if(menu_choice == 2)
    {
    cout<<setw(40)< <"\n\n ::Please enter the required information for passenger number::"<<endl ;
    cout<<"\n\n\nEn ter your first name: ";
    cin>>ws;
    cin.getline(cus tomer.firstname ,60);
    cout<<endl;
    cout<<"Enter your last name: ";
    cin>>ws;
    cin.getline(cus tomer.lastname, 60);
    cout<<endl;
    cout<<"Enter your phone number: ";
    cin>>customer.p hone;
    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(cus tomer.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(cus tomer.dest,20);
    cout<<endl<<end l;
    }
    if(menu_choice= =3)
    {
    displayMenu();
    cout<<endl;
    cin>>menu_choic e;
    }



    cout<<"To exit Press 3"<<endl;
    cin>>menu_choic e;

    count++;
    }

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

    cout<<setw(60)< <"************* *************** *********"<<end l;
    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)< <"************* *************** *********"<<end l<<endl<<endl<< endl;

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

    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)< <"************* *************** *********"<<end l;
    cout<<setw(60)< <"* (M)Premium *"<<endl;
    cout<<setw(60)< <"* (P)Platinium *"<<endl;
    cout<<setw(60)< <"* (G)Gold *"<<endl;
    cout<<setw(60)< <"************* *************** *********"<<end l<<endl<<endl<< endl;

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

    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(tpri ce,place,discou nt);

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

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

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

    OutFile<<setw(4 0)<<"Your E-Ticket is :"<<endl;
    OutFile<<"_____ _______________ _______________ _______________ _______________ _______________ _______________ ___"<<endl;
    OutFile<<" "<<endl;
    OutFile<<" ETS TRAIN TICKET "<<endl;
    OutFile<<"-------------------------------------------------------------------------------------------------"<<endl;
    OutFile<<"Reser vation No. : "<<customer.res ervation_no<<en dl;
    OutFile<<"_____ _______________ _______________ _______________ _______________ _______________ _______________ __"<<endl;
    OutFile<<"Passe nger Information : "<<endl;
    OutFile<<"Name : "<<customer.fir stname<<" "<<customer.las tname<<" "<<endl;
    OutFile<<" "<<endl;
    OutFile<<"Phone No. : 0"<<customer.ph one<<" "<<endl;
    OutFile<<"_____ _______________ _______________ _______________ _______________ _______________ _______________ __"<<endl;
    OutFile<<"Depar t : "<<customer.c_l oc<<" "<<endl;
    OutFile<<"Arriv e : "<<customer.des t<<" "<<endl;
    OutFile<<"Time Depart : "<<choose<< " AM "<<endl;
    OutFile<<"_____ _______________ _______________ _______________ _______________ _______________ _______________ __"<<endl;
    OutFile<<"Ticke t Information : "<<endl;
    OutFile<<"Statu s: "<<ch<<" "<<endl;
    OutFile<<"Seat : "<<menu.ro<<men u.start<<" "<<endl;
    OutFile<<"Food : "<<menu.foo d<<" "<<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<<e ndl<<endl<<endl ;
    cout<<" WELCOME TO OUR PEOS(PROMOTION ETS ONLINE SYSTEM)";
    cout<<"\n\n\n\n ";
    cout<<setw(60)< <"************* *************** *********"<<end l;
    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)< <"************* *************** *********"<<end l;
    }

    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*pric e;

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

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

    return nprice;
    }

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

    if (place=='A')
    tprice=1*discou nt;

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

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

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

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

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

    return tprice;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    What do you understand pseudo code to be? Maybe provide a small example.

    Comment

    Working...