Write a program with array(s) capable of storing the schedules.Create a main men
ID: 3634696 • Letter: W
Question
Write a program with array(s) capable of storing the schedules.Create a main menu that allows the user to mark a time slot as busy free for either instructor.also,add an option to output the schedules to the screen.Next,add an option to output all the time slots available for individual lessons(slots when at least one instructor is free). Finally,add an option to output all time slots available for group lessons( when both instructors are free)The instructors are Jeff and Anna and their current schedules are shown in the text book.
Explanation / Answer
please rate - thanks
please message me if there is a problem, before rating-thanks again
#include<iostream>
#include<iomanip>
using namespace std;
void set(char[][4],char[][4],char);
void output(char[][4],string);
void individual(char[][4],char[][4]);
void group(char[][4],char[][4]);
void getinfo(int&,int&,int&);
int main()
{char jeff[4][4],anna[4][4];
int i,j;
int choice=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
{anna[i][j]=' ';
jeff[i][j]=' ';
}
while(choice!=6)
{cout<<"Choose what you would like to do ";
cout<<"1 Mark time slot busy ";
cout<<"2 Mark time slot free ";
cout<<"3 output time schedule ";
cout<<"4 output timeslots for individual lessons ";
cout<<"5 output timeslots for group lessons ";
cout<<"6 Exit ";
cin>>choice;
switch(choice)
{case 1: set(anna,jeff,'X');
break;
case 2: set(anna,jeff,' ');
break;
case 3: output(anna,"ANNA");
output(jeff,"JEFF");
break;
case 4: individual(anna,jeff);
break;
case 5: group(anna,jeff);
break;
case 6: return 0;
default: cout<<"Illegal input: Try Again ";
}
}
system("pause");
return 0;
}
void getinfo(int& who,int& day,int& slot)
{cout<<"Enter 1 for Anna, 2 for Jeff: ";
cin>>who;
while(who<1||who>2)
{
cout<<"invalid entry-re try ";
cout<<"Enter 1 for Anna, 2 for Jeff: ";
cin>>who;
}
slot=5;
while(slot<0||slot>3)
{
cout<<"Enter timeslot: ";
cout<<"0 for 11-12 ";
cout<<"1 for 12-1 ";
cout<<"2 for 1-2 ";
cout<<"3 for 2-3 ";
cin>>slot;
if(slot<0||slot>3)
cout<<"Invalid entry ";
}
day=5;
while(day<0||day>3)
{
cout<<"Enter day: ";
cout<<"0 for Monday ";
cout<<"1 for Tuesday ";
cout<<"2 for Wednesday ";
cout<<"3 for Thursday ";
cin>>day;
if(day<0||day>3)
cout<<"Invalid entry ";
}
}
void set(char a[][4],char j[][4],char what)
{int who,day,slot;
getinfo(who,day,slot);
if(who==1)
a[slot][day]=what;
else
j[slot][day]=what;
}
void output(char p[][4],string name)
{int i,j;
cout<<endl<<setw(10)<<name<<" Monday Tuesday Wednesday Thursday ";
for (i=0;i<4;i++)
{cout<<setw(2)<<(i-1+11)%12+1<<"-"<<(i-1+12)%12+1;
for(j=0;j<4;j++)
cout<<setw(11)<<p[i][j];
cout<<endl;
}
cout<<endl;
}
void individual(char a[][4],char je[][4])
{char free[4][4];
int i,j;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(a[i][j]==' '||je[i][j]==' ')
free[i][j]='X';
else
free[i][j]=' ';
output(free,"Available");
}
void group(char a[][4],char je[][4])
{char free[4][4];
int i,j;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(a[i][j]==' '&&je[i][j]==' ')
free[i][j]='X';
else
free[i][j]=' ';
output(free,"Available");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.