Well heres the story...i have this problem im about to mention and i need alot of help with it....i read the Faq and i've done the best i could to get as much of the program done on my own and now i need somewhere to turn for help...nobody i know in person can help (even my professor is hard to get in touch with) and im praying somebody here will take the time to go through this with me. basically im writing a program as if i ran a restaurant and needed to assign people to thier seats (represented by a 2D array) I have 4 arrays (booth, table, smoking booth, smoking table) when the user goes in, they are asked if they want booth or table, then asked smoking or non. From there i have to go into an array (which is allready set up and filled with 'O's to mean its empty if i did that correctly) and change the O's to X's meaning someones there. When the next user request a table i have to make sure they are assigned to a whole new section of the array meaning i dont just pile them on the same table with others. Im trying to make it so the tables hold 4 people and the booths 6. I have ALOT of problems here...for one i dont have a C compiler at home and the school lab is down. If any of you can, please go through this and tell me what i should do to fix it or make it better. I know im missing alot and it needs to be cleaned up...im desperate and out of ideas. Thanks for any help....
Code:
#include<stdio.h>
char table;
char booth;
char smoketable;
char smokebooth;
// Fill the array with O's to show all seats are empty
for(I=0; I<=24; I++)
{for (J=0; J<= 3; J++)
{table[I][J] = 'O';
}
}
for(I=0; I<=9; I++)
{for (J=0; J<= 3; J++)
{booth[I][J] = 'O';
}
}
for(I=0; I<=24; I++)
{for (J=0; J<= 3; J++)
{smoketable[I][J] = 'O';
}
}
for(I=0; I<=9; I++)
{for (J=0; J<= 3; J++)
{smokebooth[I][J] = 'O';
}
}
void main(void)
{
int num1;
int num2;
printf("Hello and welcome to Empire Diner! Would you like a booth or table? Enter 1 for table, 2 for booth")
scanf("%d", &num1);
printf("Will that smoking or nonsmoking for tonight? Enter 1 for smoking, 2 for nonsmoking.");
scanf("%d", &num2);
case 1:
num1 = 1 && num2 = 1;
table(); //would this be calling the table function?
case2:
num1 = 1 && num2 = 2;
smoketable();
case3:
num1 = 2 && num2 = 1;
booth();
case4:
num1 = 2 && num2 = 2;
smokebooth();
//here is where i'd like to ask if its another customer (start over again without clearing array) or to just end the entire program. Ideas?
}
void table (void)
{
for (table = 0, table <= 24, table++)
{
if table[I][J] != 'X' //X will be used to indicate that seat is occupied
while seats < counter
{
if [J] > 4 //make sure you are not over the limit of seats for table
table[I][J] = 'X'; //still have available seat so fill it
counter++; //adds one to the counter
else
table[I][ ]++; //need new table to increment your table index (I)
table[][J] = 0; //initialize seat
table[I][J] = 'X';
counter++;
}
}
}
The rest of the functions will look like the above one, but i wont bother writing those if this one isnt even correct yet...once i see how one should look i'll make the rest. Thanks again if you straighton this mess out....