Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

data that has entered as input is not executing when we are choosing display timetable

0 votes
asked May 3, 2018 by Yasra Khan (120 points)
#include <iostream>
#include<string>
using namespace std;

struct TTcell
{
    string days[5]={"Mon","Tue","Wed","Thur","Fri"};
    char string Subject[10][10];
    string Lecturer[10][10];
    string RoomNo[10][10];
    string timee[9]={"0(9:00)","1(10:00)","2(11:00)","3(12:00)","4(1:00)","5(2:00)","6(3:00)","7(4:00)","8(5:00)"};
    int count=0;
    int n,m,z,a,ch,cd;
    char c,g,as;
    string tm;
    string dy;

};

int timedisplay(TTcell cl)
{
    for(int w=0;w<10;w++)
    {
        cout<<cl.timee[w];
        cout<<"\t";
    }
    return 0;
}
int ClearTimetable( TTcell cl)
{
        cout<<"Want to clear the timetable?\n";
        cin>>cl.as;
        if(cl.as=='y'||cl.as=='Y')
    {
        cout<<"\n\t--------------------------- Timetable------------------------------ :\n";
        cout<<"\t(0(9:00)\t1(10:00)\t2(11:00)\t3(12:00)\t4(1:00)\t5(2:00)\t6(3:00)\t7(4:00)\t8(5:00)):\n";
          
           for(int i=0;i<cl.n;i++)
           {
             for(int j=0;j<cl.m;j++)
             {
                 cl.Subject[i][j]=" ";
                 cl.Lecturer[i][j]=" ";
                 cl.RoomNo[i][j]=" ";
             }

         }

        for(int k=0;k<6;k++)
        {
            cout<<cl.days[k];

            for(int i=0;i<cl.n;i++)
         {

             for(int j=0;j<cl.m;j++)
             {

                cout<<"\t";
                cout<<cl.Subject[i][j];
                cout<<cl.Lecturer[i][j];
                cout<<cl.RoomNo[i][j];

               }
            cout<<"\n";
         }
        }
    }
    else
    cout<<"Same table\n";
   return 0;
}

int inserttimetable( TTcell cl)
{

    for(int i=1;i<=cl.n;i++)
    {
        for(int j=1;j<=cl.m;j++)
        {
                cout<<"\n"<<i<<"\t"<<j;
                cout<<"\nSubject:\n";
                    cin>>cl.Subject[i][j];
                    cout<<"\nLecturer:\n";
                cin>>cl.Lecturer[i][j];
                cout<<"\n RoomNO:\n";
                cin>>cl.RoomNo[i][j];
            }

        }
            return 0;

}
int show(TTcell cl)
{
    cout<<"\nEnter Time (0(9:00),1(10:00),2(11:00),3(12:00),4(1:00),5(2:00),6(3:00),7(4:00),8(5:00)):\n";
    cin>>cl.tm;
    cout<<"Enter Day (Mon,Tue,Wed,Thur,Fri):\n";
    cin>>cl.dy;

     for(int i=0;i<10;i++)
    {
        if(cl.timee[i]==cl.tm)
        {
            cl.z=i;
        }
        for(int j=0;j<6;j++)
        {
            if(cl.days[j]==cl.dy)
            {
                cl.a=j;
            }
        }
    cout<<" \nLecturer,Subject and Room no is:\t";

                cout<<cl.Subject[cl.z][cl.a]<<"\t";
                cout<<cl.Lecturer[cl.z][cl.a]<<"\t";
                cout<<cl.RoomNo[cl.z][cl.a]<<"\n";

    }
    return 0;
}

int showtimetable(TTcell cl)
{
   cout<<"TIMETABLE:\n";
  cout<<"\t(0(9:00)\t1(10:00)\t2(11:00)\t3(12:00)\t4(1:00)\t5(2:00)\t6(3:00)\t7(4:00)\t8(5:00)):\n";
   cout<<"\n";
   for(int k=0;k<6;k++)
   {
       cout<<cl.days[k];
      for(int i=1;i<=cl.n;i++)
     {
       for(int j=1;j<=cl.m;j++)
       {

                cout<<"\t"<<cl.Subject[i][j];
                cout<<cl.Lecturer[i][j];
                cout<<cl.RoomNo[i][j];

     }

         cout<<"\n";
     }

}
return 0;
}
int data(TTcell cl)
{
    cout<<"\nEnter No of Rows and Coloumns\n";
    cin>>cl.n;
    cout<<"\n";
    cin>>cl.m;
    do{
        cout<<"Choose the option:\n";
         cout<<"1.Clear Timetable\n";
         cout<<"2.Insert Timetable\n";
        cout<<"3.Show \n";
        cout<<"4.Show Timetable\n";
        cin>>cl.ch;
    switch(cl.ch)
    {

        case 1:     ClearTimetable(cl);
                    break;
        case 2:     inserttimetable(cl);
                    break;
        case 3:     show(cl);
                    break;
        case 4:     showtimetable(cl);
                    break;
    }
    cout<<"Do you want to access the menu?\n";
    cin>>cl.c;
   } while(cl.c=='y'||cl.c=='Y');
 return 0;
}
int main()
{
   TTcell cl;
    do{

   cout<<"Enter the Timetable you want to access:\n";
    cout<<"1.Winter\n";
    cout<<"2.Spring\n";
    cout<<"3.Summer\n";
    cout<<"4.Autumn\n";
    cin>>cl.cd;
 switch(cl.cd)
 {
     case 1:     data(cl);
                 break;
     case 2:     data(cl);
                 break;
     case 3:     data(cl);
                 break;
     case 4:     data(cl);
                 break;
 }
  cout<<"Want to enter Timetable of other season?\n";
  cin>>cl.g;
  }while(cl.g=='y'||cl.g=='Y');
 return 0;
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...