OK, i can't figure out what kind of mistake I've done. Can somebody help me please.

#include<iostream>
#include<iomanip>
using namespace std;
void scedulejeff (char [][4]);
void sceduleanna (char [][4]);
void Print2DArray(char [][4]);

int main()
{
	char jeffarray [4][4];
	char annaarray [4][4];
	char instructor;
	
	cout << "What instructor would you like to scedule a time slot for, for Jeff enter j, for Anna enter a?\n";
	cin >> instructor;
	if ((instructor==j) || (instructor==J))
	{
		scedulejeff (jeffarray);
		
	}
	if else ((instructor==a) || (instructor==A))
	{
		scedulejeff (annaarray);
	}
	else 
	{
		cout << "you entered an invalid charater please enter a 'j' for Jeff or 'a' for Anna.\n";
	}
	
}

i'm using xcode... it says there's something wrong with row 11.

instructor=='j' instead of instructor==j instructor=='J' instead of instructor==J instructor=='a' instead of instructor==a instructor=='A' instead of instructor==A

Edited 6 Years Ago by invisal: n/a

It should be else if instead of if else and there is nothing wrong with line 11. It is just warning message stated that annaarray is declared but is not used.

ok, i think i got everything right. would you mind double check it i've done something wrong... :)

#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 << "What instructor would you like to scedule a time slot for, for Jeff enter j, for Anna enter a?\n";
	cin >> instructor;
	
	if ((instructor == 'j') || (instructor == 'J'))
	{
		scedulejeff (jeffarray);
	}
	
	else if ((instructor == 'a') || (instructor == 'A'))
	{
		sceduleanna (annaarray);
	}
	
	else 
	{
		cout << "you entered an invalid charater please enter a '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 scedule.\n" 
			"enter M for Monday, T for Tuesday, W for Wednesday, or 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 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 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 entered an invalid time.\n";
					return;
					}
					break;
					   
					defaut:
					cout<< "you 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 scedule.\n" 
			"enter M for Monday, T for Tuesday, W for Wednesday, or 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 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 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 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 entered an invalid time.\n";
		return;
		}
		break;
							  
		defaut:
		cout<< "you 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++;
	}
}

Edited 6 Years Ago by omgaga: n/a

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