Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your swim school has two swimming instructors, Jeff and Anna. Their current sche

ID: 3691252 • Letter: Y

Question

Your swim school has two swimming instructors, Jeff and Anna. Their current schedules are shown below. An “X” denotes a 1-hour time slot that is occupied with a lesson.

Write a program with array(s) capable of storing the schedules. Create a main menu with the following options:

1.Allows the user to mark a time slot as busy or free for either instructor.

2.Displays the schedules to the screen.

3.Displays all time slots available for individual lessons (slots when at least one instructor is free).

4.Displays all time slots available for group lessons (when both instructors are free).

5.Loads the schedule from a file.

6.Save the schedule from a file.

Explanation / Answer

Hi below i have written the code for your reference,

#include<iostream>

#include<iomanip>

using namespace std;

void scedulejeff (char [][4]);

void sceduleanna (char [][4]);

void Print2DArray(char [][4]);

int X;

int main()

{

   char jeffarray [4][4];

   char annaarray [4][4];

   char instructor;

   cout << "Which swimming instructor would you like to choose? Enter j for Jeff, Enter a for Anna ";

   cin >> instructor;

   if ((instructor == 'j') || (instructor == 'J'))

   {

scedulejeff (jeffarray);

   }

   else if ((instructor == 'a') || (instructor == 'A'))

   {

scedulejeff (annaarray);

   }

   else

   {

cout << "You've entered an invalid alphabet. Please choose between j for Jeff, or a for Anna. ";

   }

}

void scedulejeff (char a1 [][4])

{

   char day;

   int time;

   cout << "Please enter the first letter of the day of the week you would like to schedule. "

"M for Monday, T for Tuesday, W for Wednesday, R for Thursday. ";

   cin >> day;

   cout << "Please enter a time, 11, 12, 1, or 2. ";

   cin >> time;

   switch (day)

   {

case 'M':

case 'm':

if (time == 11)

{

a1 [0][0] = X;

}

else if (time == 12)

{

a1 [1][0] = X;

}

else if (time == 1)

{

a1 [2][0] = X;

}

else if (time == 2)

{

a1 [3][0] = X;

}

else

{

cout << "You entered an invalid time. ";

return;

}

break;

case 'T':

case 't':

if (time == 11)

{

a1 [0][1] = X;

}

else if (time == 12)

{

a1 [1][1] = X;

}

else if (time == 1)

{

a1 [2][0] = X;

}

else if (time == 2)

{

a1 [3][1] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

case 'W':

case 'w':

if (time == 11)

{

a1 [0][2] = X;

}

else if (time == 12)

{

a1 [1][2] = X;

}

else if (time == 1)

{

a1 [2][2] = X;

}

else if (time == 2)

{

a1 [3][2] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

case 'R':

case 'r':

if (time == 11)

{

a1 [0][3] = X;

}

else if (time == 12)

{

a1 [1][3] = X;

}

else if (time == 1)

{

a1 [2][3] = X;

}

else if (time == 2)

{

a1 [3][3] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

defaut:

cout<< "You've entered an invalid day.";

return;

}

   }

void sceduleanna (char a1 [][4])

{

   char day;

   int time;

   cout << "Please enter the first letter of the day of the week you would like to schedule. "

"M for Monday, T for Tuesday, W for Wednesday, R for Thursday. ";

   cin >> day;

   cout << "Please enter a time, 11, 12, 1, or 2. ";

   cin >> time;

switch (day)

{

case 'M':

case 'm':

if (time == 11)

{

a1 [0][0] = X;

}

else if (time == 12)

{

a1 [1][0] = X;

}

else if (time == 1)

{

a1 [2][0] = X;

}

else if (time == 2)

{

a1 [3][0] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

case 'T':

case 't':

if (time == 11)

{

a1 [0][1] = X;

}

else if (time == 12)

{

a1 [1][1] = X;

}

else if (time == 1)

{

a1 [2][0] = X;

}

else if (time == 2)

{

a1 [3][1] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

case 'W':

case 'w':

if (time == 11)

{

a1 [0][2] = X;

}

else if (time == 12)

{

a1 [1][2] = X;

}

else if (time == 1)

{

a1 [2][2] = X;

}

else if (time == 2)

{

a1 [3][2] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

   case 'R':

   case 'r':

if (time == 11)

{

a1 [0][3] = X;

}

else if (time == 12)

{

a1 [1][3] = X;

}

else if (time == 1)

{

a1 [2][3] = X;

}

else if (time == 2)

{

a1 [3][3] = X;

}

else

{

cout << "You've entered an invalid time. ";

return;

}

break;

defaut:

cout<< "You've entered an invalid day.";

return;

}

   }

void Print2DArray(char arr1[][4])

{

   int i = 0, j;

   while (i < 3)

   {

j = 0;

   while (j < 3)

   {

   cout<<setw(5)<<arr1[i][j];

   j++;

   }

   cout<<endl;

   i++;

   }

}