Jump to content




Recent Status Updates

  • Photo
      15 Nov
    duzamucha

    Hi, I am final year Interior Design Student from University of Huddersfield. I am currently working on my final major project which is going to be linked to coding. I was hoping that you could help me with my research. I have prepared a short survey, it would be a massive help if you could fill it in for me. It takes less than 2 minutes to complete, I promise. Here is the link: https://www.surveymonkey.com/s/73XLJKK Thank you so much in advance!

View All Updates

Developed by TechBiz Xccelerator
Photo
- - - - -

help me urgent

Managed C++ form

  • Please log in to reply
11 replies to this topic

#1 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 14 November 2008 - 08:30 PM

question:
The airline company, KL AIRLINE, has engaged your teanm to develop a new Airline Ticket Reservation System....airplane wiyh the occupancy of "20 passengers".

!.display the KL "Airline Reservation Menu" for the user to select from 2 main options which are to do "Booking" and "display seat layout & occupancy".thr is one last option -to "exit" from the system after displaying an appropriate farewell message.

2.Booking
-ask user for yhe number of seat required
-Generete the Booking ID(if enough seats are available)
-for each seat required,
*ask for the passenger name,
*assign the booking ID to the seat, and
*display the ticket in following format:
-------------------------------------------------------------------------------------
| --KL airline booking tikcket---- |
| booking ID:100 Flight No.:AK65 |
| Passenger:XXXXXXXXX Date :25-12-2008 |
| Time :23:45 |
| Gate :G9 |
| seat No :3B |
---------------------------------------------------------------------------------------

note:-( Flight No,Date,Time,Gate )will be initizalized either during compile-time or run time.the details are to be stored in a "Struture variable"
-hv all the necessary "validation" in place, including useful messages, "not enough seat available"
- must use a Two Dimensional Array to store the seat information(the booking ID or a Zero value).

3.display seat layout & Occupancy
sample:
A B C D E
|--------------------------------------------|
1 |101 | 101 | 101 |102 | 103 |
|-------------------------------------------|
2 |103 |104 |104 |104 |0 |
|-------------------------------------------|
| Aisle |
|-------------------------------------------|
3 | 0 | 0 | 0 | 0 | 0 |
|-------------------------------------------|
4 | 0 | 0 | 0 | 0 |0 |
|-------------------------------------------|



******required to use :array,structure,Function***********
T.T pls help hv to submit:19 nov 2008
  • 0

#2 WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 17,226 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 14 November 2008 - 10:17 PM

What do you have so far? We won't do your homework for you, but we can help guide you to the solution.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 14 November 2008 - 10:27 PM

What do you have so far? We won't do your homework for you, but we can help guide you to the solution.

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define sizeR 4
#define sizeC 5

void menu(void);
void Booking(void);
void getinf(void);
void Display(void);

typedef struct{
	int id;
	char flightNo[40];
	char date[20];
	char time;
	char gate;
	char seatNo;
}customer;
customer cust[sizeR][sizeC];

void menu(void)
{
	int choice;

	printf("\t\t********TARC Airlene Reservation Menu*********\n");
	printf("\t\t1) Booking\n");
	printf("\t\t2) Seat Layout & Occupancy\n");
	printf("\t\t3) Exit\n");

	printf("\t\t\tYour choice : ");
	scanf("%d",&choice);

	switch(choice){
	case 1:
		Booking();
		break;
		
	case 2:
		Display();
		break;
	default:
		printf("End the program");
		break;
		
		
	}
}

void main()
{

	menu();


}

void Booking(void)
{
	customer cust[sizeR][sizeC];
	int i;
	int j;
	int row;
	int col;
	printf("How many seat are you required:\n");
	scanf("%d",&i);
	for(row=0;row<sizeR;row++){
		for(col=0;col<sizeC;col++){
			if(cust[sizeR][sizeC] != 0){
	int fp[4]={0},i,f;

	printf("hhh\n\n");

	for(i=0;i<10;i++){
		f=cust[sizeR][sizeC];
		fp[f]++;
	}
	for(i=0;i<4;i++){
		printf("%d\n\n",i,fp[i]);
	}


				





			}
		}
	}

			
				
			else
				printf("Not enough seats available!The flight is fully booked!");
}
void Display(void)
{
}
void getinf(void)
{
/*	int i;

	printf("Please enter your name:");
	scanf("%[^\n]",cust[sizeR][sizeL].name);*/
}

Edited by dky8810, 15 November 2008 - 02:28 PM.
add code tags (the # button)

  • 0

#4 WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 17,226 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 15 November 2008 - 06:16 AM

OK, now, what questions do you have to move forward? I notice that you have nothing in your display function, and your menu only lets you pick once.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 15 November 2008 - 01:53 PM

OK, now, what questions do you have to move forward? I notice that you have nothing in your display function, and your menu only lets you pick once.

if(cust[sizeR][sizeC] != 0)
the problem in this line show by my compile is binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator).
cust[sizeR][sizeC]is array of structure.
what code i need to use for know how many array element is empty ??
line 60-70

Edited by dky8810, 15 November 2008 - 02:28 PM.

  • 0

#6 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 15 November 2008 - 03:18 PM

i hv change the code :
void Booking(void)
{
int ID[4][5]={
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};


customer cust[sizeR][sizeC];
int i;
int row;
int col;
int flag=0;
printf("How many seat are you required:\n");
scanf("%d",&i);
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(0==ID[4][5]){
flag=1;
break;
}
}

if(flag==0)
printf("Please enter your name\n",cust[sizeR][sizeC].name);
else
printf("Not enough seats available!The flight is fully booked!");
}
}

in this part it keep looping how to stop it??
if(flag==0)
printf("Please enter your name\n",cust[sizeR][sizeC].name);

Edited by WingedPanther, 15 November 2008 - 05:33 PM.
add code tags (the # button)

  • 0

#7 WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 17,226 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 15 November 2008 - 05:49 PM

1) please use code tags when posting code.
2) you cannot compare a struct with 0. You have to compare an item in the struct with 0.
3) the break only breaks you out of the inner for loop, not the outer for loop.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#8 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 15 November 2008 - 10:27 PM

1) please use code tags when posting code.
2) you cannot compare a struct with 0. You have to compare an item in the struct with 0.
3) the break only breaks you out of the inner for loop, not the outer for loop.

int ID[4][5]={
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
this is "array" not struct ,so i dont understand why saying that compere a struct with 0?
the break .....can give an exemple?

int ID[4][5]={
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
this is "array" not struct ,so i dont understand why saying that compere a struct with 0?
the break .....can give an exemple?


help help!!
i no ideal for next part

question:
now is this part make me blur:what i need to write in <if>the code that can let me check still got how many empty place in my cust array??
Code:
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(0==ID[row][col]){
	for(j=0;j<i;j++){
		printf("Enter your name");
		scanf("%[\n]c",cust[sizeR][sizeC].name);

}
else{
printf("Not enough seats available!The flight is fully booked!");
can?

Edited by WingedPanther, 17 November 2008 - 09:03 AM.
triple post

  • 0

#9 WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 17,226 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 17 November 2008 - 09:05 AM

1) You are never updating array ID to non-zero values.
2) It seems like you need to sit down and create a flowchart/pseudocode of your logic. I don't have a clear sense that you have thought out what you want to do. Instead, you seem to be changing things and getting things worse, rather than better.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#10 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 17 November 2008 - 01:11 PM

void Booking(void)
{
 strcpy(cust[sizeR][sizeC].flightNo,"AK65");
 strcpy(cust[sizeR][sizeC].date,"25-12-2008");
 strcpy(cust[sizeR][sizeC].time,"23:45");
 strcpy(cust[sizeR][sizeC].gate,"G9");
 int ID[4][5]={
 {0,0,0,0,0},
 {0,0,0,0,0},
 {0,0,0,0,0},
 {0,0,0,0,0}
 };
 int con;
 int id;
 int i;
 int j;
 int row;
 int col;
 int flag=0;
 printf("How many seat are you required:\n");
 scanf("%d",&i);
 int available_seats = 0;
  for(row=0; row<sizeR; row++){
   for(col=0; col<sizeC; col++){
    if(cust[sizeR][sizeC].id == 0){
     available_seats++;
    }
   }
  }
  if(available_seats >= i){
   for(j=0;j<i;j++){
    printf("\t\t\t--- KL Airline Booking Ticket ---\n");
    cust[sizeR][sizeC].id=id;
    id++;
    printf("\t\t\tBooking ID\t:%d",&cust[sizeR][sizeC].id);
    printf("\t\t\tFlight No.:");
    scanf("%s",cust[sizeR][sizeC].flightNo);
    fflush(stdin);
    printf("\t\t\tPassenger:");
    scanf("%[\n]s",cust[sizeR][sizeC].name);
    fflush(stdin);
    printf("\t\t\tDate:");
    scanf("%s",cust[sizeR][sizeC].date);
    fflush(stdin);
    printf("\t\t\tTime:");
    scanf("%s",cust[sizeR][sizeC].time);
    fflush(stdin);
    printf("\t\t\tGate:");
    scanf("%s",cust[sizeR][sizeC].gate);
    fflush(stdin);

    printf("\t\t\tSeat No:");
    scanf("%c",&cust[sizeR][sizeC].seatNo);
    fflush(stdin);
    i++;
    system("pause");
    system("cls");
           

    /* printf("Want Countinue? press 1");
    scanf("%d",&con);
    if(con==1)
    {
     system("cls");
     Booking();
    }
    else
    {
     system("cls");
     menu();
    }*/
   }
  }



      
  else{
   printf("Not enough seats available!");
  }

why it keep looping?which line i wrong????

Edited by WingedPanther, 17 November 2008 - 02:12 PM.
fix formatting to be readable

  • 0

#11 WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderator
  • 17,226 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 17 November 2008 - 02:13 PM

You are incrementing i just as fast as you increment j. j cannot catch up to i.

Also, you did not post the entire method, and the tabs made your code unreadable. Please only use 1 or 2 spaces instead of tabs to make it more readable.
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#12 dky8810

dky8810

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 18 November 2008 - 06:44 AM

thk for all done ald!
  • 0





Also tagged with one or more of these keywords: Managed C++, form

Powered by binpress