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

please use visual studio 2010 CSCI 112 Class Project Project Descriptioin Wrile

ID: 3717837 • Letter: P

Question

please use visual studio 2010





CSCI 112 Class Project Project Descriptioin Wrile a program to assign passengers scals on a plane journey that travels fron Paris to London. Assume the plane consists of (40 seats distributed amongst different classes) with the following specificalions: » 3 Classes: o lirst ($400 pcr tickct) o Business ($300 per ticket) o Fconomy (S100 per ticket) . 10 Rows: o Row I- 2: First class o Row 3-5: Business class o Row 6-10: Lconomy class 4 Seats in each row: (A, B, C, and D) Class Row 1 Row 2 Row 3 Row 4 Row 5 Row 6 Row 7 Row 8 Row 9 Row 10

Explanation / Answer

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

namespace BookTicket
{
class Program
{
static void Main(string[] args)
{
int FirstFare = 400;
int BusFare= 300;
int EcoFare = 100;
string [,] seats = new string[10,4];
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 4; j++)
{
seats[i, j] = "*";
}
}
PrintSeats(seats );

Console.WriteLine("The price for FIrst class ticket : $" + FirstFare.ToString());
Console.WriteLine("The price for Business class ticket : $" + BusFare.ToString());
Console.WriteLine("The price for Economy class ticket : $" + EcoFare.ToString());
Console.WriteLine("Do you want to start booking??Y/y for yes, N/n for no");

string ans = Console.ReadLine();
if (ans.ToLower()!="y")
{
return;
}
bool repeat=true;
while (repeat == true)
{


Console.WriteLine("The plane has 10 rows with 4 seats in each row");
Console.WriteLine("Enter Ticket type");
Console.WriteLine("F for First Class");
Console.WriteLine("B for Business Class");
Console.WriteLine("E for Economy Class");
  
int row = 0;
bool isValidClass = false;
while (isValidClass == false)
{
ans = Console.ReadLine();

if (ans.ToLower() == "f")
{
Console.WriteLine("Row 1 and 2 are first clsss");
Console.WriteLine("Enter row number you want to sit in: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
while (true)
{
if (row == 1 || row == 2)
{
break;
}
else
{
Console.WriteLine("Error, Plz enter row which belongs to the chosen class: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
}
}
isValidClass = true;

}
else if (ans.ToLower() == "b")
{
Console.WriteLine("Row 3,4 and 5 are Business clsss");
Console.WriteLine("Enter row number you want to sit in: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
while (true)
{
if (row == 3 || row == 4 || row == 5)
{
break;
}
else
{
Console.WriteLine("Error, Plz enter row which belongs to the chosen class: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
}
}
isValidClass = true;

}
else if (ans.ToLower() == "e")
{
Console.WriteLine("Row 6,7,8,9 and 10 are Econnomy clsss");
Console.WriteLine("Enter row number you want to sit in: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
while (true)
{
if (row >= 6 && row <= 10)
{
break;
}
else
{
Console.WriteLine("Error, Plz enter row which belongs to the chosen class: ");
ans = Console.ReadLine();
row = Convert.ToInt32(ans);
}
}
isValidClass = true;

}
else
{
Console.WriteLine("Enter a valid class");
isValidClass = false;
}
}

Console.WriteLine("Enter a seat number(A to D)");
ans = Console.ReadLine();

while (true)
{
if (ans.ToLower() == "a" || ans.ToLower() == "b" || ans.ToLower() == "c" || ans.ToLower() == "d")
{
break;
}
else
{
Console.WriteLine("Error, Plz enter Correct seat number");
ans = Console.ReadLine();

}
}

while (ReserveSeats(seats, ans, row) == false)
{

}
Console.WriteLine("Do you want to continue?? Y/y for yes, N/n for No,P/p for print");
ans = Console.ReadLine();
if (ans.ToLower()=="y")
{
repeat = true;
}
else
{
repeat = false;
Console.ReadLine();
}
PrintSeats(seats);
}

}

private static bool ReserveSeats(string[,] seats,string seat,int row) {
row = row - 1;
int seatNo;
if (seat.ToLower()=="a")
{
seatNo = 0;
}
else if (seat.ToLower()=="b")
{
seatNo = 1;
}
else if (seat.ToLower() == "c")
{
seatNo = 1;
}
else if (seat.ToLower() == "d")
{
seatNo = 1;
}
else
{
Console.WriteLine("Invalid seat no");
return false ;
}

if (seats[row,seatNo ]=="X")
{
Console.WriteLine("Seat already booked");
return false ;
}
else
{
seats[row, seatNo] = "X";
return true;
}
}
private static void PrintSeats(string[,] seats)
{
Console.WriteLine("Class Row A B C D");
for (int i = 0; i < 10; i++)
{
switch (i)
{
case 0:
case 1:
Console.Write("F ");
Console.Write("Row" + (i + 1).ToString()+" ");
break;
case 2:
case 3:
case 4:
Console.Write("B ");
Console.Write("Row" + (i + 1).ToString() + " ");

break;


default:
Console.Write("E ");
Console.Write("Row" + (i + 1).ToString() + " ");


break;
}
for (int j = 0; j < 4; j++)
{
Console.Write( seats[i, j] + " ");
}
Console.WriteLine();
}

}
}
}