Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I could use some help with the following problem. The code must be in C# and mus

ID: 3840475 • Letter: I

Question

I could use some help with the following problem.

The code must be in C# and must be easy to understnd and read as I am a beginner.

--------------------------------------------------------------------------------------------------------------------------

(Airline reservation with UI)

Implement the below code with WinForm
You should be able to reuse most of logic and methods from the below code
GUI basics:
1. One button to select FIRST class
2. Second button to select ECONOMY class
3. Label INFO: that displays user message
4. Label SEATTING: that shows seats (as RESERVED or AVAILABLE) updated after each selection

Methods that might be very helpful to implement:

public bool IsFirstClassAvailable()
public bool IsEconomyClassAvailable()
public void DisplayAllSeats()
public bool[] GetAllSeats()
public bool[] GetFirstClassSeats()
public bool[] GetEconomyClassSeats()
public int ReserveFirstClassAnySeat()
public int ReserveEconomyClassAnySeat()

------------------------------------------------------------------------------------

The code that must be modified

/Include the needed packages
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//Namespace
namespace AirlineReservationSystem
{
    //Class
    class AirlineReservationSystem
    {
        //Declare the needed variables
        public static bool[] seatArray;
        public static int assignedClassI;
        public static int assignedClassII;

        //Main
        static void Main(string[] args)
        {
            //Initialize
            seatArray = new bool[11];

            //Initialize
            int classOpt = 0;

            //Loop
            for (int i1 = 0; i1 <= 10; i1++)

                //Update array
                seatArray[i1] = false;

            //Loop
            for (int i1 = 1; i1 <= 10; i1++)
            {
                //Prompt for input
                Console.WriteLine("Please type 1 for First Class or 2 for Economy Class");

                //Read input
                classOpt = Convert.ToInt32(Console.ReadLine());

                //Loop   
                while (classOpt < 1 || classOpt > 2)
                {
                    //Prompt for input
                    Console.WriteLine("Please only enter 1 or 2 for First or Economy Class");

                    //Read input
                    classOpt = Convert.ToInt32(Console.ReadLine());
                }

                //Check condition
                if (classOpt == 1)
                {
                    //Check condition
                    if (assignedClassI == 5 && assignedClassII < 5)
                    {
                        //Display message                       
                        Console.WriteLine("Sorry, first class is full.");
                        Console.WriteLine("Do you want to get a ticket for economy class? Y-N");

                        //Check condition
                        if (Console.ReadLine().Equals("N"))
                        {
                            //Display message                           
                            Console.WriteLine("Next plane leaves in 3 hours");

                            //Decrement
                            i1--;
                        }

                        //Check condition
                        else
                        {
                            //Function call
                            AssignClassII();
                        }
                    }

                    //Otherwise
                    else if (assignedClassI < 5)
                    {
                        //Function call
                        AssignClassI();
                    }
                }

                //Otherwise
                else
                {
                    //Check condition
                    if (assignedClassII == 5 && assignedClassI < 5)
                    {
                        //Display message
                        Console.WriteLine("Sorry, economy class is full.");
                        Console.WriteLine("Do you want to get a ticket for first class? Y-N");

                        //Check condition
                        if (Console.ReadLine().Equals("N"))
                        {
                            //Display message
                            Console.WriteLine("Next plane leaves in 3 hours");

                            //Decrement
                            i1--;
                        }

                        //Otherwise
                        else
                        {
                            //Function call
                            AssignClassI();
                        }
                    }

                    //Otherwise
                    else
                    {
                        //Function call
                        AssignClassII();
                    }
                }
            }

            //Display new line
            Console.WriteLine();

            //Display message
            Console.WriteLine("Sorry, The plane is full.");
            Console.WriteLine("Next one leaves in 3 hours.");

            //Read line
            Console.ReadLine();
        }

        //Method AssignClassI()
        public static void AssignClassI()
        {
            //Needed variables
            bool noDuplication = false;
            int indx = 0;

            //Create a new instance
            Random random = new Random();

            //Loop
            while (!noDuplication)
            {
                //Update
                noDuplication = true;
                indx = random.Next(1, 6);

                //Check condition
                if (seatArray[indx] == true)

                    //Update
                    noDuplication = false;
            }

            //Update
            seatArray[indx] = true;

            //Increment
            assignedClassI++;

            //Display message
            Console.WriteLine("Assigned seat {0:N0}", indx);
        }

        //Method AssignClassII()
        public static void AssignClassII()
        {
            //Needed variables
            bool noDuplication = false;
            Random random = new Random();
            int indx = 0;

            //Loop
            while (!noDuplication)
            {
                //Update
                noDuplication = true;
                indx = random.Next(6, 11);

                //Check condition
                if (seatArray[indx] == true)

                    //Update
                    noDuplication = false;
            }

            //Update
            seatArray[indx] = true;

            //Increment
            assignedClassII++;

            //Display message
            Console.WriteLine("Assigned seat {0:N0}", indx);
        }
    }
}

-------------------------------------------------------------------------

Thanks!!

Explanation / Answer

i do make implemented the program:



/Include the needed packages
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Namespace
namespace AirlineReservationSystem
{
//Class
class AirlineReservationSystem
{
//Declare the needed variables
public static bool[] seatArray;
public static int assignedClassI;
public static int assignedClassII;
//Main
static void Main(string[] args)
{
//Initialize
seatArray = new bool[11];
//Initialize
int classOpt = 0;
//Loop
for (int i1 = 0; i1 <= 10; i1++)
//Update array
seatArray[i1] = false;
//Loop
for (int i1 = 1; i1 <= 10; i1++)
{
//Prompt for input
Console.WriteLine("Please type 1 for First Class or 2 for Economy Class");
//Read input
classOpt = Convert.ToInt32(Console.ReadLine());
//Loop   
while (classOpt < 1 || classOpt > 2)
{
//Prompt for input
Console.WriteLine("Please only enter 1 or 2 for First or Economy Class");
//Read input
classOpt = Convert.ToInt32(Console.ReadLine());
}
//Check condition
if (classOpt == 1)
{
//Check condition
if (assignedClassI == 5 && assignedClassII < 5)
{
//Display message   
Console.WriteLine("Sorry, first class is full.");
Console.WriteLine("Do you want to get a ticket for economy class? Y-N");
//Check condition
if (Console.ReadLine().Equals("N"))
{
//Display message   
Console.WriteLine("Next plane leaves in 3 hours");
//Decrement
i1--;
}
//Check condition
else
{
//Function call
AssignClassII();
}
}
//Otherwise
else if (assignedClassI < 5)
{
//Function call
AssignClassI();
}
}
//Otherwise
else
{
//Check condition
if (assignedClassII == 5 && assignedClassI < 5)
{
//Display message
Console.WriteLine("Sorry, economy class is full.");
Console.WriteLine("Do you want to get a ticket for first class? Y-N");
//Check condition
if (Console.ReadLine().Equals("N"))
{
//Display message
Console.WriteLine("Next plane leaves in 3 hours");
//Decrement
i1--;
}
//Otherwise
else
{
//Function call
AssignClassI();
}
}
//Otherwise
else
{
//Function call
AssignClassII();
}
}
}
//Display new line
Console.WriteLine();
//Display message
Console.WriteLine("Sorry, The plane is full.");
Console.WriteLine("Next one leaves in 3 hours.");
//Read line
Console.ReadLine();
}
//Method AssignClassI()
public static void AssignClassI()
{
//Needed variables
bool noDuplication = false;
int indx = 0;
//Create a new instance
Random random = new Random();
//Loop
while (!noDuplication)
{
//Update
noDuplication = true;
indx = random.Next(1, 6);
//Check condition
if (seatArray[indx] == true)
//Update
noDuplication = false;
}
//Update
seatArray[indx] = true;
//Increment
assignedClassI++;
//Display message
Console.WriteLine("Assigned seat {0:N0}", indx);
}
//Method AssignClassII()
public static void AssignClassII()
{
//Needed variables
bool noDuplication = false;
Random random = new Random();
int indx = 0;
//Loop
while (!noDuplication)
{
//Update
noDuplication = true;
indx = random.Next(6, 11);
//Check condition
if (seatArray[indx] == true)
//Update
noDuplication = false;
}
//Update
seatArray[indx] = true;
//Increment
assignedClassII++;
//Display message
Console.WriteLine("Assigned seat {0:N0}", indx);
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote