For this week's assignment , create and complete a Windows application for the following question.
Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats)
Display the following alternatives: "Please type 1 for first class, and please type 2 for Economy". If the user enters 1, your application should assign a seat in the first class( seats 1-5). If the user enters 2, your application should assign a seat in the economy class( seats 6-10).
Use a one-dimensional array of bool to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the seats are empty. As each seat is assigned, set the corresponding element of the array to true to indicate that the seat is no longer available.
Your program should never assign a seat that has already been assigned. When the economy section is full, your program should ask the user if he would like to be placed in the first class, and vice-versa. If yes, make the appropriate seat assignment. if no, display the message, " Next flight leaves in 3 hours".
Remember to include comments in your code .
Here is the completed code for this problem in C#
using System;
//class representing a system to book airline tickets
class AirLine{
private bool[] seats;
//default constructor
public AirLine(){
seats=new bool[20];
//initializing all elements of seats array to false
for(int i=0;i<20;i++){
seats[i]=false;
}
}
//method to book first class ticket, returns true if booking is successful
//else false
public bool bookFirstClass(){
//looping through first 8 seats
for(int i=0;i<8;i++){
if(seats[i]==false){
//found an unsold seat, reserving it
seats[i]=true;
Console.WriteLine("You have been assigned seat number "+(i+1)+" (First Class)");
return true;
}
}
return false; //full
}
//method to book economy class ticket, returns true if booking is successful
//else false
public bool bookEconomy(){
//looping through tickets 9 to 20
for(int i=8;i<20;i++){
if(seats[i]==false){
//found unsold seat, booking the ticket
seats[i]=true;
Console.WriteLine("You have been assigned seat number "+(i+1)+" (Economy Class)");
return true;
}
}
return false; //full
}
//method to check if first class is full
public bool isFirstClassFull(){
for(int i=0;i<8;i++){
if(seats[i]==false){
//found an unsold seat
return false;
}
}
//full
return true;
}
//method to check if economy class is full
public bool isEconomyFull(){
for(int i=8;i<20;i++){
if(seats[i]==false){
//found an unsold ticket
return false;
}
}
//full
return true;
}
}; //end of AirLine class
public class Program
{
public static void Main()
{
int choice=0;
//creating an AirLine object
AirLine airline=new AirLine();
//looping until user chooses to quit
while(choice!=3){
//displaying menu
Console.WriteLine("\nType 1 for First Class or 2 for Economy, 3 to quit: ");
//getting choice
choice=Convert.ToInt32(Console.ReadLine());
//validating choice
if(choice==1){
//booking first class if it is not full
if(!airline.isFirstClassFull()){
airline.bookFirstClass();
}else if(!airline.isEconomyFull()){
//first class is full, economy is not, asking if user wants to book
//economy
Console.WriteLine("First class is full, do you want to try Economy? yes/no: ");
string ch;
ch=Console.ReadLine();
if(ch.Equals("yes")){
//booking economy ticket
airline.bookEconomy();
}else{
Console.WriteLine("Next flight leaves in 3 hours.");
}
}else{
//both classes are filled
Console.WriteLine("All seats are filled!");
}
}else if(choice==2){
//booking economy seat if it is not full
if(!airline.isEconomyFull()){
airline.bookEconomy();
}else if(!airline.isFirstClassFull()){
//economy is full, economy is not, asking if user wants to book
//first class
Console.WriteLine("Economy is full, can you afford First class? yes/no: ");
string ch;
ch=Console.ReadLine();
if(ch.Equals("yes")){
airline.bookFirstClass();
}else{
Console.WriteLine("Next flight leaves in 3 hours.");
}
}else{
Console.WriteLine("All seats are filled!");
}
}
}
}
}
/*OUTPUT*/
Type 1 for First Class or 2 for Economy, 3 to quit:
1
You have been assigned seat number 1 (First Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
1
You have been assigned seat number 2 (First Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
2
You have been assigned seat number 9 (Economy Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
2
You have been assigned seat number 10 (Economy Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
2
You have been assigned seat number 11 (Economy Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
2
You have been assigned seat number 12 (Economy Class)
Type 1 for First Class or 2 for Economy, 3 to quit:
For this week's assignment , create and complete a Windows application for the following question. Airline...
C# WINDOWS FORMS APPLICATION (not CONSOLE APPLICATION ) (Please screenshot window form of this program and write code on computer. Thank you very much !) For this week's assignment , create and complete a Windows application for the following question. Airline Reservation System: An airline has just bought a computer for its new reservation system. Develop a new system to assign seats on the new airplane( capacity: 10 seats) Display the following alternatives: "Please type 1 for first class, and...
Programming language C++. (Airline Reservations System) A small airline has just purchased a computer for its new au- tomated reservations system. You have been asked to develop the new system. You’re to write an app to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Display the following alternatives: Please type 1 for First Class and Please type 2 for Economy. If the user types 1, your app should assign a seat in the first-class section...
(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system. You'll write a program to assign seats on each flight of the airline's only plane (capacity: 10 scats).Your program should display the following menu of alternatives:Please type 1 for "first class"please type 2 for "economy"If the person types 1 , then your program should assign a seat in the first class section (seats...
I could really use some help with this question! Thanks!! Must use C# and it must be a console application ------------------------------------------------------------------------------------------------------------------------------ You start working on this w/o arrays just with seats: bool f1, f2,..., e1, e2,.... You can use Console application for now. A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You’re to write an app to assign seats on each flight of the airline’s...
C# Question. Please do a lot of documenting of what your code did and thorough explaining in your // comments. A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You’re to write an app to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Display the following alternatives: Please enter 1 for First Class or 2 for Economy. If the user types...
OBJECTIVE:The objective of the assignment is to use object-oriented design techniques to design an application.DESCRIPTION:A small airline has just purchased a computer for its new automated reservations system. You have been hired to design an airline seating application for the FBN (Fly-By-Night) Airlines. In this portion of the assignment, the task is to do the object oriented design for the application. This system will be used only by the company and its employees. Customers will not interact with the system.Your...
Write a program in C to assign seats of a movie theater (capacity: 200 seats). Your program should display the following menu of alternatives: Please type 1 for "section A, $50/ticket" type 2 for "section B, $70/ticket", and type 3 for "section C, $80/ticket". If the user types 1, then your program should assign a seat in the A section (seats 1–50). If the user types 2, then your program should assign a seat in the B section (seats 51–100). If...
Programming Language: C++ Develop a seat reservation system for your airline. Consider the following airline seating pattern: A 1 2 3 4 5 6 7 8 9 …… 100 B 1 2 3 4 5 6 7 8 9 …… 100 AISLE C 1 2 3 4 5 6 7 8 9 …… 100 D 1 2 3 4 5 6 7 8 9 …… 100 Either use 2D STL array (array that contains array) or 4 single dimensional STL arrays of size 100. Write a program to display a menu to the user with the options to reserve a seat of choice, reserve a window seat, reserve an aile seat, reserve a seat (any available), withdraw reservation, update reservation (change seat) and display...
I have to write a C program to assign seats on each flight of the airline’s only plane (capacity: 40 seats, in 10 rows). For the sake of simplicity, assume that each row has 4 seats labeled A, B, C, D. Your program should display the following menu of alternatives: Please type 1 for "first class" Please type 2 for "business class" Please type 3 for “economy class”. If the person types 1, then your program should assign a seat...
The Course Project can be started in Week 7 and is due by 11:59 pm CT Saturday of Week 8. It must follow standard code formatting and have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does. Pseudocode must be provided in the comment block at the top of the file. This program will allow the...