This program will allow the user to keep track of airline reservations. The prog
ID: 3650777 • Letter: T
Question
This program will allow the user to keep track of airline reservations. The program should display the seating chart for the airplane. It will use an * to indicate a seat is taken and the # to indicate the seat is available. The program will also display a menu which provides the user with several options. There will be two types of seats in the airplane: first class and coach, each of which will have a different cost. The program must make use of files, arrays and functions.The airplane will have 5 rows in the first class section with 4 seats in each row, 2 on each side of the aisle and 10 rows in the coach section with 3 seats on each side of the aisle. The prices for all the first class seats will be the same. The first 5 rows of coach will be more expensive than the last 5 rows. The prices for the seats will be stored in a file called SeatPrices.txt . The program should read these values from the file and store the values in an array of doubles. This is an example of the seating chart:
12 34
Row 1 ## ##
Row 2 ## ##
Row 3 ## ##
Row 4 ## ##
Row 5 ## ##
123 456
Row 6 ### ###
Row 7 ### ###
Etc.
The menu will provide choices to reserve a seat(s) and display the total number of seats sold (indicating first class and coach), the total number of seats empty in a row, the total number of seats empty in the plane (indicating first class and coach), and the total amount of sales (in dollars).
Validation: The seat requested by the user is a valid row and seat number. The program should also make sure the seat is not already taken.
Can anyone help give me a jump start on this? I'd appreciate any help or tips.
Explanation / Answer
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Assign7 extends JApplet implements ActionListener { JButton firstClassButton, economyClassButton; JTextField displayField; boolean[] seat; int i; public void init() { Container container = getContentPane(); container.setLayout(new FlowLayout()); firstClassButton = new JButton("First Class"); firstClassButton.addActionListener(this); container.add(firstClassButton); economyClassButton = new JButton("Economy"); economyClassButton.addActionListener(this); container.add(economyClassButton); displayField = new JTextField(20); displayField.setEditable(false); container.add(displayField); seat = new boolean[11]; } public void actionPerformed(ActionEvent actionEvent) { if( actionEvent.getSource() == firstClassButton ) { reserve(true); displayField.setText("Seat " + i + " has been reserved"); } else if( actionEvent.getSource() == economyClassButton ) { reserve(false); displayField.setText("Seat " + i + " has been reserved"); } } int reserve(boolean firstClass) { if(firstClass = true) { for(i = 1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.