can help me ?? i want to loop to "Please choose the section you want" after all the calculation, but it only loop to "key in the number of adults"..Please help..

#include <iostream>

using namespace std;

int main ()
{

    int adults1, childrens1, adults2, children2, adultstotal, childrentotal, choices, total_ticket1 = 0, total_ticket2 = 0, sessions;

    int total_day = ( total_ticket1+total_ticket2 );



          sessions = 0;
    cout << " Please choose the sessions you want " << endl;
    cout << " Key in 1 for 2pm to 4pm session " << endl;
    cout << " Key in 2 for 8pm to 10pm session " << endl;
    cin >> sessions ;

        if ( sessions == 1 && sessions != 0 ) {

        cout << " Welcome to Zoo Melaka " << endl;
        cout << " This is 2pm to 4pm session " << endl;
        cout << " To exit, key in 0 for both adults and children " << endl; 

            while ( total_ticket1 < 50 ) {
                int adult1, children1;
                cout << " Key in the number of adults " << endl;
                cin >> adults1;
                total_ticket1 += adults1;
                cout << " Key in the number of children that below 12 years old " << endl;
                cin >> children1;
                total_ticket1 += children1;

                    if ( adults1 == 0 && children1 == 0 ) break; 

                else {

                int adultstotal_1 = ( adults1*10);
                int childrentotal_1 = ( children1*5);
                int total = ( adultstotal_1+childrentotal_1);
                int ticket1 = (adults1+children1);
                cout << " The total amount is " << total << endl;

                int choice;
                cout << " Do you want to print receipt? " << endl;
                cout << " Key in 1 to print receipt " <<endl;
                cout << " Key in 2 to exit " << endl;
                cin >> choices;
                    if ( choices != 1 || choices == 2 )break;

                    else if ( choices == 1 || choices != 2 ){
                        cout << "The receipt for the purchase is:" << endl;
                        cout << "Adult      " << adults1  << "    RM" << adultstotal_1 << endl;
                        cout << "Children   " << children1 << "    RM" << childrentotal_1 << endl;
                        cout << "Total      " << ticket1 << "    RM" << total << endl;
                    }

                }   

                 if  ( total_ticket1 > 50 ){
                    cout << " Exceed total ticket allowed !! " << endl;
                    cout << " Please key in less ticket :" << endl;
                }

                else if  ( total_ticket1 == 50 ) {
                    cout << " Warning!! The ticket was sold out " << endl;
                    cout << " Please come again! " <<endl;
                }


                    int choice;
                    int total_day = (total_ticket1 + total_ticket2);
                    cout << " Insert 1 to accept " << endl;
                    cout << " Insert 2 to terminate the program " << endl;
                    cin >> choice;

                    if ( choice == 2 ) break;

                    else if ( choice == 1 ){
                        cout << " Total ticket that had been sold are " << total_ticket1 << endl;
                        cout << " Total ticket sold by today are " << total_day << endl;
                    }
                        system("pause"); 
                }   
          }     
            if ( sessions == 2 && sessions != 0 ) {

                    cout << " Welcome to Zoo Melaka " << endl;
                    cout << " This is 8pm to 10pm session " << endl;
                    cout << " To exit, key in 0 for both adults and children " << endl; 


            while ( total_ticket2 < 50 ) {
                int adult2, children2;
                cout << " Key in the number of adults " << endl;
                cin >> adults2;
                total_ticket2 += adults2;
                cout << " Key in the number of children that below 12 years old " << endl;
                cin >> children2;
                total_ticket2 += children2;

                    if ( adults2 == 0 && children2 == 0 ) break; 

                else {

                int adultstotal_2 = ( adults2*10);
                int childrentotal_2 = ( children2*5);
                int total = ( adultstotal_2+childrentotal_2);
                int ticket2 = (adults2 + children2);
                cout << " The total amount is " << total << endl;

                int choices;
                cout << " Do you want to print receipt? " << endl;
                cout << " Key in 1 to print receipt " <<endl;
                cout << " Key in 2 to exit " << endl;
                cin >> choices;
                    if ( choices != 1 || choices == 2 )break;

                    else if ( choices == 1 || choices != 2 ){
                        cout << "The receipt for the purchase is:" << endl;
                        cout << "Adult      " << adults2  << "    RM" << adultstotal_2 << endl;
                        cout << "Children   " << children2 << "    RM" << childrentotal_2 << endl;
                        cout << "Total      " << ticket2 << "    RM" << total << endl;
                    }

                }   

                 if  ( total_ticket2 > 50 ){
                    cout << " Exceed total ticket allowed !! " << endl;
                    cout << " Please key in less ticket :" << endl;
                }

                else if  ( total_ticket2 == 50 ) {
                    cout << " Warning!! The ticket was sold out " << endl;
                    cout << " Please come again! " <<endl;
                }


                    int choice;
                    int total_day = (total_ticket1 + total_ticket2);
                    cout << " Insert 1 to accept " << endl;
                    cout << " Insert 2 to terminate the programme " << endl;
                    cin >> choice;

                    if ( choice == 2 ) break;

                    else if ( choice == 1 ){
                        cout << " Total ticket that had been sold are " << total_ticket2 << endl;
                        cout << " Total ticket sold by today are " << total_day << endl;


                    }

                system("pause"); 


                      }      


          }



return 0;
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

My first suggestion would be to read up on functions, and then split main() into something more manageable (say 1 function per top-level menu option).

Several hundred lines of poorly indented code isn't good to read.

Actually, after all the calculate , i wan to return "if" loop there..but it only able to return to ?while" loop there...anything wrong on my coding?

Not exactly understand..can you give me a example to refer ? sorrry i am a beginner.

I guess you just need to implement another option in your menus. Like "Press 3 to go to main menu..." then you can use goto ______; and what not... or you can think of something better.

I don't get what you are trying to do though. If you are trying to make like a ticket seller program there are far better ways to do it. For starters, use functions....

This article has been dead for over six months. Start a new discussion instead.