ONLY USE VISUAL STUDIO C# CONSOLE APPLICATION (NO JAVA CODING) PLEASE POST THE O
ID: 3833781 • Letter: O
Question
ONLY USE VISUAL STUDIO C# CONSOLE APPLICATION
(NO JAVA CODING)
PLEASE POST THE OUTPUT ALSO
Create a C# Console program that will demonstrate the use of File IO, Arrays, and Classes.
This assignment has a number of requirements. Carefully read the document and note all the requirements. Also keep in mind that many of the requirements for this assignment are module; that is if one requirement is not implemented, it will not affect another. For example, you can implement adding a seat without having removing a seat working. You can reserve and unreserve seats without having saving and loading working. To maximize your mark, try to complete as many requirements as possible, do not get stuck on one requirement and spend all of your time trying to get it to work at the neglect of other requirements.
Write a program that functions as a concert/restaurant/airplane/etc. reservation system. This system must be sufficiently complex, with a minimum of 4 rows with 4 seats in each row. You must display the seats on the screen in some manner and indicate which are available and which are taken, it is up to you to decide how to do this. You may display the seating in any display format that you feel is appropriate as long as it logically conveys the information to the user. [4 Marks]
Example seating chart:
*Seat 1-1*Seat 1-2*Seat 1-3*Seat 1-4*
*Seat 2-1*Seat 2-2*Seat 2-3*Seat 2-4*
*Seat 3-1*Seat 3-2*Seat 3-3*Seat 3-4*
*Seat 4-1*Seat 4-2*Seat 4-3*Seat 4-4*
Allow the user the following options:Add a customer to the seating plan [8 Marks]
Request the customer's name
Display a list of the seats in the venue
If seats are available, let the customer choose a seat. Add the customer to the seating chart on the application.
For example, after adding a customer the seating chart would become:
*************************************
*Seat 1-1*Seat 1-2*Seat 1-3*S. Claus*
*Seat 2-1*Seat 2-2*Seat 2-3*Seat 2-4*
*Seat 3-1*Seat 3-2*Seat 3-3*Seat 3-4*
*Seat 4-1*Seat 4-2*Seat 4-3*Seat 4-4*
*************************************
If no seats are available, inform the user
Remove a customer from the seating plan [4 Marks]
Request the customer's name or seat number
Search the seating chart for the customer's name or seat number and delete it
Your system should show validation whenever appropriate, and function in a logical manner. For example, the system should not shut down after each operation, if a user has to fix an entry the system should not start over, etc. [5 Marks]
Your system should also have File IO such that the reserved seats with who reserved them is not lost when your program shuts down.
Explanation / Answer
#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
// Function prototypes
void seatChart(double FirstArray[FirstROWS][FirstCOLS], double Coach1Array [CoachROWS][CoachCOLS],
double Coach2Array[CoachROWS][CoachCOLS]);
void displayMenu(double, double FirstArray[FirstROWS][FirstCOLS], double Coach1Array[CoachROWS][CoachCOLS],
double Coach2Array[CoachROWS][CoachCOLS]);
int main()
{
// Variables
double choice = 0;
const int FIRSTCLASS = 1,
FIRSTCOACH= 2,
SECONDCOACH = 3,
DISPLAYSEAT = 4,
EXIT = 5;
//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
//double seatssold, seatsremainrow, totalsales, totalempty;
// Arrays
double FirstArray[FirstROWS][FirstCOLS];
double Coach1Array[CoachROWS][CoachCOLS];
double Coach2Array[CoachROWS][CoachCOLS];
// intro
cout << "Welcome to my Airline Seat Reservation System" << endl;
cout << "============================================= " << endl;
//seatChart(FirstArray, Coach1Array, Coach2Array);
displayMenu(choice, FirstArray,Coach1Array,Coach2Array);
return 0;
}
// This is a function to display the menu
void displayMenu(double, double FirstArray[FirstROWS][FirstCOLS], double Coach1Array[CoachROWS][CoachCOLS],
double Coach2Array[CoachROWS][CoachCOLS])
{
// Variables
int CHOICE;
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
const int FIRSTCLASS = 1,
FIRSTCOACH = 2,
SECONDCOACH = 3,
DISPLAYSEAT = 4,
EXIT = 5;
double firstprice;
double coach1price;
double coach2price;
cout << "Please pick from the following options: 1-5" << endl;
cout << "======================================" << endl;
cout << "1. First Class" << endl;
cout << "2. First Coach Class" << endl;
cout << "3. Second Coach Class" << endl;
cout << "4. Display Available seating" << endl;
cout << "5. Exit " << endl;
cin >> CHOICE;
//Opens input files
ifstream inputFile;
inputFile.open("SeatPrices.txt");
// Checks for failure.
if (inputFile.fail())
{
cout << "Sorry File does not exist or can not be found. ";
exit(1);
}
// read the numbers and load them into doubles
inputFile >> firstprice;
inputFile >> coach1price;
inputFile >> coach2price;
// closing file
inputFile.close();
// Switch statement
switch (CHOICE)
{
case FIRSTCLASS :
cout << "You have chosen: First Class" << endl;
cout << " The price of a ticket for First Class is:" << firstprice << endl;
cout << " Now please pick which row you would like to sit in: (1-5) ";
cin >> fcrow;
if (fcrow > 5)
{
cout << " You have entered an invalid row number, please enter in between 1-5 ";
cin >> fcrow;
}
cout << " Please pick which seat you would like to sit in, please enter between 1-4 ";
cin >> fccol;
if (fccol > 4)
{
cout << " You 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 << " The price of a ticket for First Coach Class is $" << coach1price << endl;
cout << " Now 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 << " You have entered an invalid row number, please enter between 6-10 ";
cin >> fccrow;
}
cout << " Please 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 << " The price of a ticket for Second Coach Class is: $"<< coach2price << endl;
cout << " Now please pick which row you would like to sit in, please choose between 11-15 ";
cin >> scrow;
if (fccrow > 15)
{
cout << " You 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;
case DISPLAYSEAT:
seatChart(FirstArray, Coach1Array, Coach2Array);
break;
case EXIT:
cout << "You have chosen to Exit the program" << endl;
cout << "Thank you for using my program, have a good day!" << endl;
exit(1);
break;
default: cout << "You have entered in an invalid choice, please pick between 1-5" << endl;
}
}
// This is a Funciton for the Seating Chart
void seatChart(double FirstArray[FirstROWS][FirstCOLS], double Coach1Array[CoachROWS][CoachCOLS],
double Coach2Array[CoachROWS][CoachCOLS])
{
cout << "This is the Seating Chart" << endl;
cout << "========================= " << endl;
cout << "First Class is seats 1-4, Rows 1-5 " << endl;
for (int a = 0; a < FirstROWS; a++)
{
for (int b = 0; b < FirstCOLS; b++)
cout << FirstArray[a] << " " << FirstArray[b] << endl;
cout << endl;
}
cout << " First Coach Class are seats 1-6, Rows 6-10:" << endl;
for (int a = 0; a < CoachROWS; a++)
{
for (int b = 0; b < CoachCOLS; b++)
cout << Coach1Array[a] << " " << Coach1Array[b] << endl;
}
cout << endl;
cout << " Second Coach Class are seats 1-6, Rows 11-15" << endl;
for (int a = 0; a < CoachROWS; a++)
{
for (int b = 0; b < CoachCOLS; b++)
cout << Coach2Array[a] << " " << Coach2Array[b] << endl;
}
cout << endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.