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++;
	}
}

in case you guys wanna know what the question for the code is;

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

Jeff Monday Tuesday Wednesday Thursday

11-12 X X

12-1 X X X

1-2 X X

2-3 X X X

Anna Monday Tuesday Wednesday Thursday

11-12 X X X

12-1 X X

1-2 X X

2-3 X X X

Write a program with arrays capable of storing the schedules. Create a main menu that allows the user to mark a time slot as busy or free for either instructor. Also, add an option to output the schedules to the screen. Next, add an option to output all 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 instructures are free)

Your program should employ the following:


·
as indicated in the problem description: 2 two-dimensional arrays, one for Jeff’s
schedule, and one for Anna’s

·
a main menu that provides options to the user

·
a function that prints the schedule

·
a function that prompts the user to select an
instructor, day, and slot

·
a function that prompts the user, then schedules
or frees one of the instructor's slots.
This function calls the second function described above.

·
comments as appropriate (refer to the homework
guidelines)

On line 45 you're cout-ing time, not cin-ing it.

thanks!!!

First of all, a1 [0][0] = X should be a1[0][0] = 'X'; because you want to assign character X to an element in your characters array. It also apply to a1[1][0] , a1[2][0] , a1[3][0] , etc...

Secondly, you declare two arrays of characters without initiate them.

This article has been dead for over six months. Start a new discussion instead.