Question

In: Computer Science

Please use c# and write a console application Part 1) A small airline has just purchased...

Please use c# and write a console application

Part 1) A small airline has just purchased a computer for its newly automated reservations system. You have been asked to develop a new system. You are to write an application to assign seats on each flight of the airline’s only plane. The plane has ten rows and each row has 2 seats (total capacity: 20 seats). The first five rows are for first class passengers, while the remaining rows are for economy passengers. The application is used by an airline employee who is given the task of assigning all seats to passengers (one passenger at a time). Your application should display the following alternatives: Please type 1 for First Class and Please type 2 for Economy or type 3 to see the status of all seats. If the user types 1, your application should assign a seat in the first-class section (rows 1–5). If the user types 2, your application should assign a seat in the economy section (rows 6–10).
If the user types 3, the application will display the status of all seats (“A” for available and “X” for booked) as shown below. The application will continue to ask for the user’s input until the flight is full or the user suggests that they do not want to assign anymore seats.
Availability Status:
X   X
X   X
X   A
A   A
A   A

X   X
X   X
X   X
X   X
A   A

Your application should never assign a seat that has already been assigned. When the economy section is full, your application should ask the person if it is acceptable to be placed in the first-class section (and vice versa). If yes, make the appropriate seat assignment. If no, display the message "Next flight leaves in 3 hours." You will need to use a multi-dimensional array to solve this problem. 

Part 2) Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write an application (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson’s salary is truncated to an integer amount):
a) $200–299
b) $300–399
c) $400–499
d) $500–599
e) $600–699
f) $700–799
g) $800–899
h) $900–999
i) $1000 and over
The application will accept sales amount until the user enters -1 to end (as shown in figure 2.1 below). At this point, the application calculates the salary and updates the appropriate counter of the array. For instance, if the salesperson gets a total salary of $565, you will update the counter that is counting totals between the $500-$599 range.

Figure 2.1. Receiving input from user

Note that you do NOT need to store the individual salary of the salesperson. Summarize the results in tabular format Use only a for loop to display the output.


Final output showing all ranges and the number of agents that received commission in that range

Solutions

Expert Solution

Part 1)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Automated_reservations_system
{
class Program
{
static void Main(string[] args)
{
char[,] Seats = new Char[10, 2];
for(int i=0;i<10;i++)
{
Seats[i, 0] = 'X';
Seats[i, 1] = 'X';
}
int choice;
while (true)
{
menu();
choice = Convert.ToInt16(Console.ReadLine());
switch (choice)
{
case 1:
bookFirstClassTicket(Seats);
break;
case 2:
bookEconomyClassTicket(Seats);
break;
case 3:
printSeates(Seats);
break;
default:
Console.WriteLine("Invalid Option! Please try again....");
break;
}
}

}

private static void printSeates(char[,] Seats)
{
Console.WriteLine("\nAvailability Status:");
for (int i = 0; i < 10; i++)
Console.WriteLine(Seats[i, 0] + "\t" + Seats[i, 1]);
}
public static void menu()
{
Console.WriteLine("\nPlease type 1 for First Class\nPlease type 2 for Economy\nPlease Type 3 to see the status of all seats.");
Console.Write("Emter your choice: ");
}
public static void bookFirstClassTicket(char [,]seats)
{
if (checkSeatAvaibility(seats, 'F'))
{
for (int i = 4; i >= 0; i--)
{
if (seats[i, 0] == 'X')
{
seats[i, 0] = 'A';
break;
}
else if (seats[i, 1] == 'X')
{
seats[i, 1] = 'A';
break;
}
}
Console.WriteLine("You ticket has been booked. Enjoy your journey.");
}
else
{
if (!checkSeatAvaibility(seats, 'E'))
{
Console.WriteLine("\nSorry! No tickets are available. Next flight leaves in 3 hours");
}
else
{
string c;
Console.Write("\nNo ticekts is available in First class do you want to book Economy class ticket?(y/n):");
c = Console.ReadLine();
if (c == "y" || c == "Y")
bookEconomyClassTicket(seats);
else
Console.WriteLine("\nNext flight leaves in 3 hours.");
}
}
}
public static void bookEconomyClassTicket(char[,] seats)
{
if (checkSeatAvaibility(seats, 'E'))
{
for (int i = 9; i >= 5; i--)
{
if (seats[i, 0] == 'X')
{
seats[i, 0] = 'A';
break;
}
else if (seats[i, 1] == 'X')
{
seats[i, 1] = 'A';
break;
}
}
Console.WriteLine("\nYou ticket has been booked. Enjoy your journey.");
}
else
{
if (!checkSeatAvaibility(seats, 'F'))
{
Console.WriteLine("\nSorry! No tickets are available. Next flight leaves in 3 hours");
}
else
{
string c;
Console.Write("\nNo ticekts in Economy class do you want to book first class ticket?(y/n):");
c = Console.ReadLine();
if (c == "y" || c == "Y")
bookFirstClassTicket(seats);
else
Console.WriteLine("\nNext flight leaves in 3 hours.");
}
}
}
public static bool checkSeatAvaibility(char[,] seats, char type)
{
bool isAvailable = false;
if (type == 'F')
{
for (int i = 4; i >= 0; i--)
{
if (seats[i, 0] == 'X' || seats[i, 1] == 'X')
{
isAvailable = true;
break;
}
}
}
else
{
for (int i = 9; i >= 5; i--)
{
if (seats[i, 0] == 'X' || seats[i, 1] == 'X')
{
isAvailable = true;
break;
}
}
}
return isAvailable;
}
}
}

outputs

Part 2)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EmployeeSalary
{
class Program
{
static void Main(string[] args)
{
int[] salariesArray = new int[9];
Array.Clear(salariesArray, 0, salariesArray.Length);
int salesAmount;
int salary;
while (true)
{
Console.Write("Enter your salars amont or -1 to stop: ");
salesAmount = Convert.ToInt32(Console.ReadLine());
if (salesAmount == -1)
break;
salary = (int)(200 +0.09 * salesAmount);
if (salary <= 299)
salariesArray[0]++;
else if (salary >= 300 && salary <= 399)
salariesArray[1]++;
else if (salary >= 400 && salary <= 499)
salariesArray[2]++;
else if (salary >= 500 && salary <= 599)
salariesArray[3]++;
else if (salary >= 600 && salary <= 699)
salariesArray[4]++;
else if (salary >= 700 && salary <= 799)
salariesArray[5]++;
else if (salary >= 800 && salary <= 899)
salariesArray[6]++;
else if (salary > 900 && salary <= 999)
salariesArray[7]++;
else
salariesArray[8]++;
}
int s=200;
Console.WriteLine("\n\nSalary Range\tCount");
for (int i = 0; i < 9; i++)
{
Console.WriteLine("$" + s + " - " + (s + 99)+"\t"+salariesArray[i]);
s += 100;
}
}
}
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations...
(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 seats). 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...
(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations...
(Airline Reservations System) A small airline has just purchased a computer for its new automated reservations system. You’ve been asked to develop the new system. You’re to write an application to assign seats on each flight of the airline’s only plane (capacity: 500 seats).Your application should display the following alternatives: Please type 1 for First Class and Please type 2 for Economy. If the user types 1, your application should assign a seat in the first class section (seats 1–250)....
C# I need working code please Write a console application that accepts the following JSON as...
C# I need working code please Write a console application that accepts the following JSON as input: {"menu": { "header": "SVG Viewer", "items": [ {"id": "Open"}, {"id": "OpenNew", "label": "Open New"}, null, {"id": "ZoomIn", "label": "Zoom In"}, {"id": "ZoomOut", "label": "Zoom Out"}, {"id": "OriginalView", "label": "Original View"}, null, {"id": "Quality"}, {"id": "Pause"}, {"id": "Mute"}, null, {"id": "Find", "label": "Find..."}, {"id": "FindAgain", "label": "Find Again"}, {"id": "Copy"}, {"id": "CopyAgain", "label": "Copy Again"}, {"id": "CopySVG", "label": "Copy SVG"}, {"id": "ViewSVG", "label": "View...
PLease use c++ Write a checkbook balancing program. The program will read in, from the console,...
PLease use c++ Write a checkbook balancing program. The program will read in, from the console, the following for all checks that were not cashed as of the last time you balanced your checkbook: the number of each check (int), the amount of the check (double), and whether or not it has been cashed (1 or 0, boolean in the array). Use an array with the class as the type. The class should be a class for a check. There...
write a c# console application app that reads all the services in the task manager and...
write a c# console application app that reads all the services in the task manager and automatically saves what was read in a Notepad txt file.  Please make sure that this program runs, also add some comments
C# Write a console application that takes the following passage and removes every instance of the...
C# Write a console application that takes the following passage and removes every instance of the word "not" using StringBuilder and prints the result out to the console: I do not like them In a house. I do not like them With a mouse. I do not like them Here or there. I do not like them Anywhere. I do not like green eggs and ham. I do not like them, Sam-I-am. Ensure that the resulting output reads normally, in...
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance....
Loops Write a simple C/C++ console application that will calculate the equivalent series or parallel resistance. Upon execution the program will request ether 1 Series or 2 Parallel then the number of resisters. The program will then request each resistor value. Upon entering the last resistor the program will print out the equivalent resistance. The program will ask if another run is requested otherwise it will exit.
Using C# .NET Core console application that contains the following: 1. Use this variable: string baconIpsum...
Using C# .NET Core console application that contains the following: 1. Use this variable: string baconIpsum = "Bacon ipsum dolor amet picanha tri-tip pig pork bacon turducken. Leberkas short ribs prosciutto pork belly ribeye capicola alcatra short loin ham hock rump jowl pig flank beef. Venison tenderloin tail, cupim salami pastrami meatball jerky filet mignon. Salami jerky short loin, chicken pig pork tenderloin rump meatball sausage pancetta sirloin. Drumstick tenderloin ham pork belly cupim, ground round prosciutto jerky ball tip...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...
You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:         ● Subtotal using a cost of $3.50 per yogurt.         ● Subtotal...
You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks...
You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks a postal address. Prompt for and get from the user an address. Use function getline so that the address can contain spaces. Loop through the address and count the following types of characters:         ● Digits (0-9)         ● Alphabetic (A-Z, a-z)         ● Other Use function length to control the loop. Use functions isdigit and isalpha to determine the character types. Use formatted...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT