ok, i have a bigger problem. when i run the program (something like this);
"Which swimming instructor would you like to choose? Enter j for Jeff, Enter a for Anna
j
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.
m
Please enter a time, 11, 12, 1, or 2.
0You entered an invalid time."
the problem is, i only put j, and m myself. i didn't put 0 myself. what's the problem?
here's the entire code
#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\n";
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.\n";
}
}
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.\n"
"M for Monday, T for Tuesday, W for Wednesday, R for Thursday.\n";
cin >> day;
cout << "Please enter a time, 11, 12, 1, or 2.\n";
cout << 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.\n";
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.\n";
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.\n";
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.\n";
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.\n"
"M for Monday, T for Tuesday, W for Wednesday, R for Thursday.\n";
cin >> day;
cout << "Please enter a time, 11, 12, 1, or 2.\n";
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.\n";
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.\n";
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.\n";
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.\n";
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++;
}
}