I'm currently working a project for class and I am stuck. I am a complete newbie when it comes to programming and I am trying my best, so if my code looks off, please let me know where I am going wrong. Anyways here are the guidelines for my project:
This program will allow the user to keep track of airline reservations. The program should display the seating chart for the airplane. It will use an * to indicate a seat is taken and the # to indicate the seat is available. The program will also display a menu which provides the user with several options. There will be two types of seats in the airplane: first class and coach, each of which will have a different cost. The program must make use of files, arrays and functions.
The airplane will have 5 rows in the first class section with 4 seats in each row, 2 on each side of the aisle and 10 rows in the coach section with 3 seats on each side of the aisle. The prices for all the first class seats will be the same. The first 5 rows of coach will be more expensive than the last 5 rows. The prices for the seats will be stored in a file called SeatPrices.txt . The program should read these values from the file and store the values in an array of doubles. This is an example of the seating chart:
12 34
Row 1 ## ##
Row 2 ## ##
Row 3 ## ##
Row 4 ## ##
Row 5 ## ##
123 456
Row 6 ### ###
Row 7 ### ###
Etc.
The menu will provide choices to reserve a seat(s) and display the total number of seats sold (indicating first class and coach), the total number of seats empty in a row, the total number of seats empty in the plane (indicating first class and coach), and the total amount of sales (in dollars).
Validation: The seat requested by the user is a valid row and seat number. The program should also make sure the seat is not already taken.
I am mainly having problem with my output for the seating chart, I don't know how to get the values of the array to show up as # and *. Can anyone please help me out with this???
#include <iostream>
#include <iomanip>
#include <fstream> // allows for the importing of file.
#include <string>
using namespace std;
// Constants
const int FirstCOLS = 4; // Columns for First class
const int FirstROWS = 5; // Rows for First class
const int CoachCOLS = 6; // Columns for Coach class
const int CoachROWS = 5; // Rows for Coach class
//const string Avail = "#"; // Available
//const string Taken = "*"; // Taken
//int fcrow, fccol; // first class rows and columns inputs
//int fccrow, fcccol; // first coach class row and columns inputs
//int scrow, sccol; // second coach class row and column inputs
int fcrow, fccol; // first class rows and columns inputs
int fccrow, fcccol; // first coach class row and columns inputs
int scrow, sccol; // second coach class row and column inputs
switch (CHOICE)
{
case FIRSTCLASS :
cout << "You have chosen: First Class" << endl;
cout << "\nThe price of a ticket for First Class is:" << firstprice << endl;
cout << "\nNow please pick which row you would like to sit in: (1-5) ";
cin >> fcrow;
if (fcrow > 5)
{
cout << "\nYou have entered an invalid row number, please enter in between 1-5 ";
cin >> fcrow;
}
cout << "\nPlease pick which seat you would like to sit in, please enter between 1-4 ";
cin >> fccol;
if (fccol > 4)
{
cout << "\nYou have entered an invalid seat number, please enter between 1-4 ";
cin >> fccol;
}
break;
case FIRSTCOACH:
cout << "You have chosen: First Coach Class" << endl;
cout << "\nThe price of a ticket for First Coach Class is $" << coach1price << endl;
cout << "\nNow please pick which row you would like to sit in: ";
cin >> fccrow;
cout << "Please pick which seat you would like to sit in. Please enter between 6-10: ";
cin >> fcccol;
if (fccrow > 10)
{
cout << "\nYou have entered an invalid row number, please enter between 6-10 ";
cin >> fccrow;
}
cout << "\nPlease pick which seat you would like to sit in, please enter between 1-6: ";
cin >> fccol;
if (fcccol > 6)
{
cout << "You have entered an invalid seat number, please enter between 1-6";
cin >> fcccol;
}
break;
case SECONDCOACH:
cout << "You have chosen: Second Coach Class" << endl;
cout << "\nThe price of a ticket for Second Coach Class is: $"<< coach2price << endl;
cout << "\nNow please pick which row you would like to sit in, please choose between 11-15 ";
cin >> scrow;
if (fccrow > 15)
{
cout << "\nYou have entered an invalid row number, please enter in between 11-15 ";
cin >> scrow;
}
cout << "Please pick which seat you would like to sit in: ";
cin >> sccol;
if (fcccol > 6)
{
cout << "You have entered an invalid seat number, please enter between 1-6";
cin >> sccol;
}
break;