i am writing a program for seats reservation... here is the thing....
we have only one airplane with 10 seats...
type (1) for expensive seat
type (2) for cheap seat
type (0) for exit
you have to use seats[10] array
and you have to do seats[10]={0};
if you type (1) you have to point the reservation by doing the elements (0-4) of seats[10] from (0) to (1)
if you type (2) you have to point the reservation by doing the elements (5-9) of seats[10] from (0) to (1)
if you type (1) and all expensive seats are reserved you have to ask if the customer wants a cheap seat.
if you type (2) and all cheap seats are reserved you have to ask if the customer wants an expensive seat.
if all seats are reserved the program must say "the next flight is at 4 hours"
here is what i 've done so far....
#include <stdio.h>
#include <stdlib.h>
int x=0;
int i=0;
int j=0;
int z=0;
int seats[10]={0};
int main() {
printf ("Please type 1 for expensive seat\n");
printf("Please type 2 for cheap seat\n");
printf("Please type 0 for exit\n");
scanf ("%d",&x);
while ((x!=1) && (x!=2) && (x!=0)){
printf ("wrong type\n");
printf (">Please type 1 for expensive seat\n");
printf("Please type 2 for cheap seat\n");
printf("Please type 0 for exit\n");
scanf ("%d",&x);}
for (i=0; i<10; i++)
if (x=1){
for (j=0; j<5; j++){
if (seats[j]=0){
seats[j]=1;
j=j+5; }
if (seats[j]=1){
printf ("all expensive seats are reserved\n\n");
printf ("would you like a cheap seat?\n\n"); }
scanf ("%d",&x);}}
else if (x=2) {
for (j=5; j<10; j++){
if (seats[j]=0){
seats[j]=1;
j=j+5; } }
if (seats[j]=1){
printf ("all cheap seats are reserved\n\n");
printf ("would you like expensive seat?\n\n"); } }
system ("pause");
return 0;
}
i m testing it to see how I am going to this but it does not work....
any solutions?
sorry for my english... r not good... i translated the problem from greek...