Note: This is a C# program with console output! Please read all instructions, as
ID: 3850595 • Letter: N
Question
Note: This is a C# program with console output! Please read all instructions, as this is not the airline reservation system program found on the net.
1 Overview
In this assignment, you will use the .NET Collection Classes to build a simulation of an airline ticket counter.
2 Problem Assignment
You have the misfortune to have a taken a job in the IT department of Paranoid Airlines ("They Hate To Fly, And They Hate You, Too!"). Paranoid Airlines has just received the "award" for the worst customer service ever (so bad that even the cable companies look good in comparison). So, they want you to do some simulations to just see how bad their business has become.
Paranoid Airlines arranges their check-in counters so that they have one customer service position for Economy passenger, Business Class passengers, and First Class passengers. They also have three lines, one line for each class of passenger.
2.1 A few rules
If the line for First Class passengers is empty, then the agent serving the First Class line can assist customers in the Business Class line.
If the line for First Class passengers is empty and the line for Business Class passengers is empty, then the agent on the First Class line can assist passengers in the Economy line.
If the line for Business Class passengers is empty, then the agent at the Business Class customer position will first see if there are customers in the First Class line. If that line is empty, then the customer service agent will service customers in the Economy line.
If the Economy class line is empty, then the customer service agent in that position will assist First Class passengers first, and then Business class passengers.
2.2 Customer arrival rates and service times
The system will keep a simulated clock that starts at zero and counts the simulated number of minutes in the simulation.
The simulation will run 12 hours (or 720 minutes).
Customers will randomly arrive in the Economy line at the rate of 1 every 3 simulated minutes
Customers will randomly arrive in the Business Class line at the rate of 1 every 15 simulated minutes.
Customers will randomly arrive in the First Class line at the rate of 1 every 30 simulated minutes
It takes a customer service agent randomly between 5 - 10 minutes to assist an Economy Class customer
It takes a customer service agent randomly between 6-12 minutes to assist a Business Class customer
It takes a customer service agent randomly between 5 - 20 minutes to assist an First Class customer
2.3 Output
Your simulation needs to run for a simulated 12 hours (720 minutes). Every 10 time ticks, your program needs to display how many customers are in each line and whether or not a customer agent is assisting the customer.
At the end of the simulation, your program needs to display the average time customers spent in each line, the total numbers of customers assisted in each class, and the average and maximum length of each line over the course of simulation
2.4 Implementation requirements
Don't do this as one large function in your Main() method. You're using an object-oriented language… take advantage of that fact.
Don't implement your own data structures! Use the classes in the System.Collection.Generic framework.
Use Console output.
Explanation / Answer
using System;
class AirlineResevationSystem
{
static void Main()
{
int seatsFirst, seatsEconomy, reserve, i = 0, j = 6;
bool[] seats = { false, false, false, false, false,
false, false, false, false, false };
Console.WriteLine("Welcome to Airline System.");
while (true)
{
Console.WriteLine("There are " + checkFirstClass(out seatsFirst, seats) + " first class seats and " + checkEconomy(out seatsEconomy, seats) + " economy seats.");
Console.WriteLine("Please 1 to reserve a first class seat or enter 2 to reserve an economy class seat or 0 to exit");
reserve = Convert.ToInt32(Console.ReadLine());
if (reserve == 1)
{
if (i > 5 || i == 5)
{
Console.WriteLine("There are no first class seats available.");
reserve = Convert.ToInt32(Console.ReadLine());
}
else reserveFirstSeat(ref seats, ref i);
}
else if (reserve == 2)
{
if (j < 5 || j > 10)
{
Console.WriteLine("There are no economy seats available.");
reserve = Convert.ToInt32(Console.ReadLine());
}
else reserveEconomySeat(ref seats, ref j);
}
else if (reserve == 0)
{
Console.WriteLine("Next flight leaves in three hours.");
break;
}
else
{
Console.WriteLine("Invalid entry. Please try again");
}
}
}
public static int checkFirstClass (out int seatsFirst, bool [] seats)
{
seatsFirst = 0;
for (int i = 0; i<5; i++)
{
if (seats[i] == false)
seatsFirst++;
}
return seatsFirst;
}
public static int checkEconomy (out int seatsEconomy, bool [] seats)
{
seatsEconomy = 0;
for (int i = 5; i<10; i++)
{
if (seats[i] == false)
seatsEconomy++;
}
return seatsEconomy;
}
public static void reserveFirstSeat (ref bool [] seats, ref int i)
{
if (i<5)
{
if (seats[i] == false)
{
seats[i] = true;
Console.WriteLine("You have successfully reserved a first class seat");
}
}
++i;
}
public static void reserveEconomySeat (ref bool [] seats, ref int j)
if (j > 5 || j == 5 || j<10)
{
if (seats[j] == false)
{
seats[j] = true;
Console.WriteLine("You have successfully reserved an economy class seat");
}
}
++j;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.