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
<< "Menu of Seating Options" << endl
<< " 1) First Class" << endl
<< " 2) Economy" << endl
<< "Please enter your choice: ";
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
<< "Incorrect choice!" << endl
<< "Please select again." << endl;
return;
}
void DisplayBoardPass(int section, int seatnbr)
{
cout << endl
<< "Boarding Pass for Rosalyn's Airline International" << endl
<< "Section: " << section << endl
<< "Seat number: " << seatnbr << endl
<< endl;
return;
}
void DisplayAltChoice(int section)
{
cout << endl
<< "The " << ((section == First_Class) ? "First Class " : "Economy"
<< "section is full." << endl
<< "Would you like to reserve a seat in the "
<< ((section == First_Class) ? "Ecomony " : "First Class "
<< "section?(Y/N): ";
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 <<"Next Flight leaves in 3 hours.";
return;
}
void DisplayFlightDepart()
{
cout <<"Flight now ready for departure.";
return;
}
void DisplayEndMenu()
{
cout << "Thank You for using Rosalyn's Airline Reservation System!" endl
<< "Please come again and Have a Nice Day!" endl
return;
}
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
<< "Menu of Seating Options" << endl
<< " 1) First Class" << endl
<< " 2) Economy" << endl
<< "Please enter your choice: ";
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
<< "Incorrect choice!" << endl
<< "Please select again." << endl;
return;
}
void DisplayBoardPass(int section, int seatnbr)
{
cout << endl
<< "Boarding Pass for Rosalyn's Airline International" << endl
<< "Section: " << section << endl
<< "Seat number: " << seatnbr << endl
<< endl;
return;
}
void DisplayAltChoice(int section)
{
cout << endl
<< "The " << ((section == First_Class) ? "First Class " : "Economy"
<< "section is full." << endl
<< "Would you like to reserve a seat in the "
<< ((section == First_Class) ? "Ecomony " : "First Class "
<< "section?(Y/N): ";
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 <<"Next Flight leaves in 3 hours.";
return;
}
void DisplayFlightDepart()
{
cout <<"Flight now ready for departure.";
return;
}
void DisplayEndMenu()
{
cout << "Thank You for using Rosalyn's Airline Reservation System!" endl
<< "Please come again and Have a Nice Day!" endl
return;
}