My Struct was looping and working well, Till i Added in a New Struct and add that to the Loop,

Now its not Working that well plus not outputting the Details only the hours.
could some one help me with this..

struct Trains 
{
    int Train_Id;                   //train ID
    string Station_Origin;             //Station of Origin
    int Departure_Time ;            //Departure Time
    string Destination_Station;        //Station of Destination
    int Arrival_Time ;              //Arrival Time
   
};

struct Station
{
    string intermediate_station1;    //intermediate_station
    int Arrival_time1;             // Arrival time to intermediate_station
    string intermediate_station2;      //intermediate_station2
    int Arrival_time2;             // Arrival time to station2 
    string intermediate_station3;     // intermediate_station1
    int Arrival_time3;             // Arrival time to station3 
};
struct Station record[3];
    struct Trains  myArray[10];
    int N_STATION;
    int N_TRAIN;
    int n;
    int i; 
    N_TRAIN = -1;
    
    if (choice == 1)
    {
        do 
        {
            cout  << " Enter number of Trains on Track: " <<endl;
            
            cin >> N_TRAIN;
            cout << endl;        
        }
        
        while(N_TRAIN > 10 || N_TRAIN < 0);
        
        for(n=0; n < N_TRAIN; n++)
        {
            while((cout<<" Enter Train ID: ")&&(!(cin>>myArray[n].Train_Id)||myArray[n].Train_Id <0))
            {
                cout<<" Invalid Input! Please Enter Train ID: "<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
            
            cout << " Name of Station of Origin: ";
            cin >> myArray[n].Station_Origin;
            
            while((cout<<"Enter Departure Time: Please Enter 24hr!")&&(!(cin>>myArray[n].Departure_Time)||myArray[n].Departure_Time < 0))
            {
                cout<<" Invalid Input! Enter Departure Time: Please Enter 24hr !"<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
            
            cout << " Name of Destination Station: ";
            cin >> myArray[n].Destination_Station;
            
            
            while((cout<<" Enter Arrival Time: Please Enter 24hr! ")&&(!(cin>>myArray[n].Arrival_Time)||myArray[n].Arrival_Time < 0))
            {
                cout<<" Invalid Input! Enter Arrival Time: Please Enter 24hr! "<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
        
            N_STATION = -1; 
            
            do
            { 	cout  << "Enter number of intermediate station please Enter 3: " <<endl;
                
                cin >> N_STATION;
                cout << endl;
            }
            
            while(N_STATION > 3 || N_STATION < 0);
            for(n=0; n < N_TRAIN; n++)    
        
                
            cout << " Name of Station of intermediate station 1: ";
            cin >> record[i].intermediate_station1;
            
            while((cout<<" Enter Arrival Time For intermediate station: Please Enter 24hr!")&&(!(cin>>record[i].Arrival_time1)||record[i].Arrival_time1 < 0))
            {
                cout<<" Invalid Input! Enter Arrival Time For intermediate station: Please Enter 24hr!"<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
            
            
            cout << " Name of Station of intermediate station 1: ";
            cin >> record[i].intermediate_station2;
            
            while((cout<<" Enter Arrival Time For intermediate station: Please Enter 24hr!")&&(!(cin>>record[i].Arrival_time2)||record[i].Arrival_time2 < 0))
            {
                cout<<" Invalid Input! Enter Arrival Time For intermediate station: Please Enter 24hr!"<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
            
            cout << " Name of Station of intermediate station 1: ";
            cin >> record[i].intermediate_station3;
            
            while((cout<<" Enter Arrival Time For intermediate station: Please Enter 24hr!")&&(!(cin>>record[i].Arrival_time3)||record[i].Arrival_time3 < 0))
            {
                cout<<" Invalid Input! Enter Arrival Time For intermediate station: Please Enter 24hr!"<<endl;
                cin.clear();
                cin.ignore(1000,'\n'); 
                
            }
            
 
        
    }
        
    }
for (n=0; n < N_TRAIN ;n++)
        {		
            
            cout << " Name of Station of Origin: "    << "  " <<  myArray[n].Station_Origin          << endl;   
            cout << "\n"                                                                            << endl;
            cout << "Arrival Time: "                  << "  " << myArray[n].Arrival_Time << "Hours"                   << endl;  
            cout << "\n"                                                                            << endl;
            cout << " Name of Destination Station: "  << "  " <<  myArray[n].Destination_Station     << endl;
            cout << "\n"                                                                            << endl;
            cout << "Departure Time: "                << "  " <<  myArray[n].Departure_Time <<"Hours"                 << endl; 
            cout << "\n"                                                                            << endl;
            
            for (i = 0; i < N_STATION;i++)
                
            cout << " Name of Station of intermediate station 1: " << "  "   <<record[i].intermediate_station1           << endl;
            cout << "\n"                                                                            << endl;
            cout << " Arrival Time For intermediate station 1: "   << "  "   << record[i].Arrival_time1 << "Hours"      << endl;
            cout << "\n"                                                                            << endl;
            cout << " Name of Station of intermediate station 2: " << "  "   <<record[i].intermediate_station2           << endl;
            cout << "\n"                                                                            << endl;
            cout << " Arrival Time For intermediate station 2: "   << "  "   << record[i].Arrival_time2 << "Hours"      << endl;
            cout << "\n"                                                                            << endl;
            cout << " Name of Station of intermediate station 3: " << "  "   <<record[i].intermediate_station3           << endl;
            cout << "\n"                                                                            << endl;
            cout << " Arrival Time For intermediate station 3: "   << "  "   << record[i].Arrival_time3 << "Hours"      << endl;
            
        }

        
    }

Why are you looping over the number-of-trains, inside your loop to input Trains structs, at line 65? And without an opening "{" (and closing "}" some time later), the only line that will be looped-over is the prompt for the first intermediate station name.

I suspect that in adding the additonal struct, you may have misinterpreted the assignment. If there is only one track, then the station-names need to be provided in only one place. And the only values that need to be maintained on a per-train basis are the arrival and departure times from the origin, intermediate stations, and destination.

If you think about what information you need to maintain, then the data structures to help you organize that information may be more obvious, along with the coding necessary to input and display the information.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.