I want to make a program in order to book airplane's seats.
My idea was that the user have to type 1 for first seat, 2 for economical seat and 0 for exit..
so i begin, i thought that i have to use an array, switch-case, with two functions, one for 1-5 seats booking, and another with 6-10, but i was confused..
My work so far:
Code:
#include <iostream>
#include <stdlib.h>
using namespace std;
int function_a(int[]);
int main()
{
const int size = 10;
int myArray[size];
unsigned short int num;
for (int i=0;i<size;i++)
{
myArray[i]=0;
}
cout<<"Please, type 1 for First seat, 2 for Economical seat or 0 to exit:"<<endl;
cin>>num;
switch(num)
{
case 1:cout<<"1 seat taken in element:"<<function_a(myArray);
break;
case 0:
return 0;
break;
}
cout<<endl;return main();
system("PAUSE");
return 0;
}
int function_a(int array[])
{
int element;
for (int j=0;j<6;j++)
{
element=array[0+j]=1;
}
return element;
}
my problem is that i can not figure a method in order to book 1 seat and go to another..