Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

statement missing; in function

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
0
0
US
Morning,

I am using Turbo 4.5 Borland for C++. Currently working on a program of an Airline Reservation system. The program is suppose to assign seats for FirstClass and Economy section. Once they select their section I am suppose to assign them a seat number and print a boarding pass that will display their section and seat number. However when I debug I receive the below error message and can not find what could be wrong with the code. Below I have attached the error message and my codes. Any help would be greatly appreciated
******************error message***************************
Error AIRLINE.CPP 81: Statement missing; in function DisplayBoardPass(int, int)
Warning AIRLINE.CPP 86: Parameter 'section' is never used in function DisplayBoardPass(int, int)
Warning AIRLINE.CPP 86: Parameter 'seatnbr' is never used in function DisplayBoardPass(int, int)
************end****error message***************************
//Airline.cpp

#include <iostream.h>
#define YES 1
#define NO 2
#define First_Class 1
#define Economy 2

void DisplayMenu(void);
int getMenuSelection(void);
int AssignSeats(int section);
void DisplayMenuErr(void);
void DisplayBoardPass(int section, int seatnbr);
void DisplayAltChoice(void);
void DisplayNextFlight(void);
void DisplayEndMenu(void);

int FirstClassAssign = 0;
int EconomyAssign = 0;

int main(void)
{
int section;
int seatnbr;

DisplayMenu();
section = getMenuSelection();
seatnbr = AssignSeats(section);
DisplayBoardPass(section, seatnbr);
return 0;
}
void DisplayMenu()
{
cout << endl
<< &quot;Menu of Seating Options&quot; << endl
<< &quot; 1) First Class&quot; << endl
<< &quot; 2) Economy&quot; << endl
<< &quot;Please enter your choice: &quot;;
return;
}
int getMenuSelection ()
{
int selection;
cin >> selection;
getMenuSelection();
if ((selection != First_Class) && (selection != Economy))
{
DisplayMenuErr();
return getMenuSelection();
}
return selection;
}
int AssignSeats(int section)
{
int FirstClassSeatNbr = 0;
int EconomySeatNbr = 4;

if (section == First_Class)
{
FirstClassSeatNbr++;
return FirstClassSeatNbr;
}
else
{
EconomySeatNbr++;
return EconomySeatNbr;
}
}
void DisplayMenuErr()
{
cout << endl
<< &quot;Incorrect choice!&quot; << endl
<< &quot;Please select again.&quot; << endl;
return;
}
void DisplayBoardPass(int section, int seatnbr)
{
cout << endl
<< &quot;Boarding Pass for Rosalyn's Airline International&quot; endl
<< &quot;Section: &quot; << section << endl
<< &quot;Seat number: &quot; << seatnbr << endl
<< endl;
return;
}
//void DisplayAltChoice()
//{
// cout << &quot;First Class is currently full.&quot; endl
// << &quot;Would you like to reserve a seat in the Ecomony section?&quot; endl
// << &quot;Please enter(Y/N): &quot; endl;
// return;
//)
//void DisplayNextFlight()
//{
// cout <<&quot;Next Flight leaves in 3 hours.&quot;;
// return;
//}
//void DisplayEndMenu()
//{
// cout << &quot;Thank You for using Rosalyn's Airline Reservation System!&quot; endl
// << &quot;Please come again and Have a Nice Day!&quot; endl
// return;
//}

 
The error is int this statement (missing the << befor endl):
Code:
    cout << endl
          << &quot;Boarding Pass for Rosalyn's Airline International&quot; endl

should be:
Code:
    cout << endl
          << &quot;Boarding Pass for Rosalyn's Airline International&quot; << endl

Good luck.
 
A tip on understanding the error message:

I'll bet it doesn't really say, &quot;Statement missing; in function...&quot;

It probably says, &quot;Statement missing ; in function...&quot;.

Or, in other words, &quot;Statement missing semicolon in function...&quot;
 
Hi again!! I am receiving an error message of:
Warning AIRLINE.CPP 124: Unreachable code in function DisplayAltChoice(int)
Error AIRLINE.CPP 124: Expression syntax in function DisplayAltChoice(int)
Error AIRLINE.CPP 135: 'DisplayAltChoice(int)' cannot return a value in function DisplayAltChoice(int)
Error AIRLINE.CPP 137: Declaration terminated incorrectly

Below is the coding below. Any help is greatly appreciated!!

//Airline.cpp
#include <iostream.h>
#define YES 1
#define NO 2
#define First_Class 1
#define Economy 2

void DisplayMenu(void);
int getMenuSelection(void);
int AssignSeats(int section);
int SectionFull (int section);
char getAltResponse (void);
char PlaneFull (void);
void DisplayMenuErr(void);
void DisplayAltChoice(int section);
void DisplayNextFlight(void);
void DisplayFlightDepart(void);
void DisplayBoardPass(int section, int seatnbr);
void DisplayEndMenu(void);

int FirstClassAssign = 0;
int EconomyAssign = 0;
int FirstClassSeatNbr = 0;
int EconomySeatNbr = 4;
char response;

int main(void)
{
int section;
int seatnbr;
do
{
DisplayMenu();
section = getMenuSelection();
if (SectionFull(section) == NO)
{
seatnbr = AssignSeats(section);
DisplayBoardPass(section, seatnbr);
}
else
{
DisplayAltChoice(section);
response = getAltResponse();
if (response == 'Y')
{
section = (section == First_Class) ? Economy : First_Class;
seatnbr = AssignSeats(section);
DisplayBoardPass(section, seatnbr);
}
else
DisplayNextFlight();
}
} while (PlaneFull() == NO);
DisplayFlightDepart();
return 0;
}
void DisplayMenu()
{
cout << endl
<< &quot;Menu of Seating Options&quot; << endl
<< &quot; 1) First Class&quot; << endl
<< &quot; 2) Economy&quot; << endl
<< &quot;Please enter your choice: &quot;;
return;
}
int getMenuSelection ()
{
int selection;
cin >> selection;
if ((selection != First_Class) && (selection != Economy))
{
DisplayMenuErr();
return getMenuSelection();
}
return selection;
}
int SectionFull(int section)
{
if (section == First_Class)
return (FirstClassSeatNbr == 5);
else
return (EconomySeatNbr == 10);
}
int AssignSeats(int section)
{
if (section == First_Class)
{
FirstClassSeatNbr++;
return FirstClassSeatNbr;
}
else
{
EconomySeatNbr++;
return EconomySeatNbr;
}
}
void DisplayMenuErr()
{
cout << endl
<< &quot;Incorrect choice!&quot; << endl
<< &quot;Please select again.&quot; << endl;
return;
}
void DisplayBoardPass(int section, int seatnbr)
{
cout << endl
<< &quot;Boarding Pass for Rosalyn's Airline International&quot; << endl
<< &quot;Section: &quot; << section << endl
<< &quot;Seat number: &quot; << seatnbr << endl
<< endl;
return;
}
void DisplayAltChoice(int section)
{
cout << endl
<< &quot;The &quot; << ((section == First_Class) ? &quot;First Class &quot; : &quot;Economy&quot;)
<< &quot;section is full.&quot; << endl
<< &quot;Would you like to reserve a seat in the &quot;
<< ((section == First_Class) ? &quot;Ecomony &quot; : &quot;First Class &quot;)
<< &quot;section?(Y/N): &quot;;
return;
)
char getAltResponse()
{
cin >> response;
if (response == 'y')
response = 'Y';
else if (response == 'n')
response = 'N';
if ((response != 'Y') && (response != 'N')
}
DisplayMenuErr();
return getAltResponse();
}
return response;
}
char PlaneFull (void)
{
if ((SectionFull(First_Class) == YES) && (SectionFull(Economy) == YES))
return = YES;
else
return = NO;
}
void DisplayNextFlight()
{
cout <<&quot;Next Flight leaves in 3 hours.&quot;;
return;
}
void DisplayFlightDepart()
{
cout <<&quot;Flight now ready for departure.&quot;;
return;
}
void DisplayEndMenu()
{
cout << &quot;Thank You for using Rosalyn's Airline Reservation System!&quot; endl
<< &quot;Please come again and Have a Nice Day!&quot; endl
return;
}
 
read a bit what is error about, where is it, correct it and compille again

Ion Filipski
1c.bmp
 
The DisplayAltChoice(...) function ends with ( instead of a {

You should realy try to read your code more carefuly. It is true that the C++ compilers return some strage messages, and sometimes they don't give you a clue about what's wrong with your code, but they point the portion of code that's buggy (eg. the function DisplayAltChoice()).

I believe this forum should be used for real problems, not manual code compiling.
 
Actualy, it ends with a ) instead of a }, but I think you got the clue.
 
1. New problems should be posted in new threads, especially when the old thread is a month dead. Not only is it good ettiquette, you'll get more people to read the thread when they don't think it's the same thing all over again.


2. As ivalentin points out, the error message points you to the general place where you're getting the error. Post that part of the code.

Hopefully, you understand that posting:

Code:
//Airline.cpp
#include <iostream.h>
#define YES    1
#define NO    2
#define First_Class    1
#define Economy        2

void DisplayMenu(void);
int getMenuSelection(void);
int AssignSeats(int section);
int SectionFull (int section);
char getAltResponse (void);
char PlaneFull (void);
void DisplayMenuErr(void);
void DisplayAltChoice(int section);
void DisplayNextFlight(void);
void DisplayFlightDepart(void);
void DisplayBoardPass(int section, int seatnbr);
void DisplayEndMenu(void);

int FirstClassAssign = 0;
int EconomyAssign = 0;
int FirstClassSeatNbr = 0;
int EconomySeatNbr = 4;
char response;
...

doesn't help anyone tell you what's wrong. Make use of this common sense by only posting relevant code.

In other words, reduce the problem to the smallest possible example that still exhibits the same behavior. Often, if you just do this in the first place, you won't even have to ask since you'll end up solving your own problem. Often, if you think this way in the first place, you won't even run into the problem.

Failing that, post only the code that's giving you the error message and a reasonable amount of surrounding code.


3. Another typo, you start your "if" statement in that function with a } instead of a {.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top