Code:
#!/usr/bin/perl
# script name: seating_plan.pl
# script to book seats in a commercial airplane
use strict;
use warnings;
my @seat_cols = qw( A B C D E F);
open(FH, "<", "seating.txt") or die "file seating.txt cannot
be opened: $!";
my @seating = <FH>;
close(FH);
my $usr_choice = "";
while($usr_choice !~ /QUIT/i ){
# printing seat plan chart for the
user
print "\t";
print $_, "\t" foreach(@seat_cols);
print "\n";
for(my $i=0; $i < scalar @seating; $i++){
my @row = split(/,/,
$seating[$i]);
print "Row ",$i+1, "\t";
foreach (@row){
print $_,
"\t";
}
print "\n";
}
print "\n\tFirst Class: rows 1 through 2";
print "\n\tBusiness Class: rows 3 through 7";
print "\n\tEconomy Class: rows 8 through 13";
print "\n";
# Taking the ticket type and seat number as
input
print "\nEnter ticket type : ";
my $type = <STDIN>;
print "\nEnter seat number : ";
my $seat = <STDIN>;
chomp($seat);
$seat=~/(\d+)([A-F])/;
my ($row, $col) = ($1,$2);
my $class;
$class = 'First' if($row >=1 && $row
<=2);
$class = 'Business' if($row >=3 && $row
<=7);
$class = 'Economy' if($row >=8 && $row
<=13);
my $i;
# blocking the seat number if available
if(defined $seating[$row-1]){
my @tarr = split(/,/,
$seating[$row-1]);
foreach($i=0; $i<scalar @tarr;
$i++){
if($seat_cols[$i] eq $col && $tarr[$i] eq '*'){
$tarr[$i] = 'X';
$seating[$row-1] = join(',', @tarr);
print "\nSeat number $seat available for class
$class and is booked...\n";
#print "\n", $seating[$row-1];
last;
}
elsif($seat_cols[$i] eq $col && $tarr[$i] eq 'X'){
print "\nSorry seat not available for seat
number $seat. Try another seat...\n";
}
}
}
# checking if user want to continue, otherwise user
can provide 'quit' to exit
print "\nDo you want to continue booking ?(Type 'QUIT'
to exit from menu and 'Yes' to continue) ";
$usr_choice = <STDIN>;
chomp($usr_choice);
}
Script input file:
186590cb0725:Chegg bonkv$ cat seating.txt
*,*,X,*,X,X
*,X,X,*,X,X
*,*,X,X,X,X
*,*,X,*,*,X
*,*,X,*,X,X
X,*,X,*,X,X
*,X,X,*,X,X
*,*,*,*,X,X
*,*,X,*,X,X
*,*,*,X,X,X
*,*,X,*,*,X
*,*,X,*,X,X
186590cb0725:Chegg bonkv$
Script execution and output:
186590cb0725:Chegg bonkv$ perl seating_plan.pl
A B C
D E F
Row 1 * * X
* X X
Row 2 * X X
* X X
Row 3 * * X
X X X
Row 4 * * X
* * X
Row 5 * * X
* X X
Row 6 X * X
* X X
Row 7 * X X
* X X
Row 8 * * *
* X X
Row 9 * * X
* X X
Row 10 * * *
X X X
Row 11 * * X
* * X
Row 12 * * X
* X X
First Class: rows 1 through 2
Business Class: rows 3 through 7
Economy Class: rows 8 through 13
Enter ticket type : First
Enter seat number : 1D
Seat number 1D available for class First and is booked...
Do you want to continue booking ?(Type 'QUIT' to exit from menu
and 'Yes' to continue) yes
A B C
D E F
Row 1 * * X
X X X
Row 2 * X X
* X X
Row 3 * * X
X X X
Row 4 * * X
* * X
Row 5 * * X
* X X
Row 6 X * X
* X X
Row 7 * X X
* X X
Row 8 * * *
* X X
Row 9 * * X
* X X
Row 10 * * *
X X X
Row 11 * * X
* * X
Row 12 * * X
* X X
First Class: rows 1 through 2
Business Class: rows 3 through 7
Economy Class: rows 8 through 13
Enter ticket type : First
Enter seat number : 1D
Sorry seat not available for seat number 1D. Try another seat...
Do you want to continue booking ?(Type 'QUIT' to exit from menu
and 'Yes' to continue) quit
186590cb0725:Chegg bonkv$
For c++ Write a program that can be used to assign seats for a commercial airplane....
In C++. Write a program that can be used to assign seats for a commercial airplane and print out the ticket total. The airplane has 13 rows, with row 7 being the Emergency Exit row. Each row has 7 seats, there are two seats on each side of the plane and three seats in the middle with aisles on both sides. Rows 1 and 2 are considered first class with tickets for this specific flight being $872.00 round trip. Rows 3...
Need help with this, please!Write a java program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class, rows3 to 7 are business class, and rows 8 to 13 are economy class. Your program prompts the user to enter the following information:- Ticket type (first class or economy class)- For economy class, the smoking or non-smoking section- Desired seatOutput the seating...
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...
Hello, I am working on a project for my C++ class, I have the vast majority of the code figured out but am running into a few issues. Mainly updating each * to an X. The problem is as follows:(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with six seats in each row. Rows 1 and 2 are first class, rows 3 through 7 are business...
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...
Using C not C++, Write a program that can be used by a small theater to sell tickets for performances. The theater’s auditorium has 15 rows of seats, with 30 seats in each row. The program should display a screen that shows which seats are available and which are taken. For example, the following screen shows a chart depicting each seat in the theater. Seats that are taken are represented by an * symbol, and seats that are available are...
Can you help us!! Thank you!
C++
Write a program that can be used by a small theater to sell tickets for performances. The program should display a screen that shows which seats are available and which are taken. Here is a list of tasks this program must perform • The theater's auditorium has 15 rows, with 30 seats in each row. A two dimensional array can be used to represent the seats. The seats array can be initialized with...
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...
Labs CSIT 210 Introduction to Programming LAB 9B Arrays Change the program AirlineDriver.java to assign passenger seats in an airplane. Chesapeake Airlines is a small commuter airline with seats for 20 passengers in 5 rows of 4 seats each. Here is the layout: 1ABCD 2ABCD 3ABCD 4ABCD 5ABCD The user enters the row (1 – 5) and the seat (A – D). The seat entry may be lowercase. Use this code to enter the seat: System.out.print(" Enter row and seat...
The language is C++ for visual studio express 2013 for windows create a TicketManager class and a program that uses the class to sell tickets for a performance at a theater. Here are all the specs. This is an intense program, please follow all instructions carefully. -I am only creating the client program that uses the class and all it's functions -The client program is a menu-driven program that provides the user with box office options for a theater and...