Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Only Please The program you will create is to allow a user to enter the type of seats on an airplane they would like

Java Only Please

The program you will create is to allow a user to enter the type of seats on an airplane they would like (first class, business class, coach economy) and you will write the code that will prompt them for the category they want to purchase and you will print out the number of seats available for that type of seat category. You will also code the other requirements listed below. You will use the 2 parallel arrays, seats[ ] = {5, 3, 1, 2} and price[ ] = {1200, 850, 600, 450} ; seats[ ] represents the number of seats available for each category - seats[0] = 5, which mean there are 5 seats available in first class. seats[1] = 3 which means there are 3 seats available in business class, etc. price [ ] represents the price for each of the categories of seats: price[0] = 1200 which means a first class seat costs 1200 dollars.

First Goal:

Your user should be allowed to enter the amount of money they have to spend, ie : $550 and you have to determine which seats they can purchase for that amount of money.

Example: If the user enters $550, then you should output that they are able to buy only economy which is category 3.

Accomplish this in a method - qualify () which will return the highest category available at the price entered by the user.

Second le Goal:

Your user should be allowed to enter the category they decide and you output the number of seats available at that floor.

Example: If the user enters Coach (can also be represented by a 2 for the index), you will tell them there is 1 seat available for that category.

Acclomplish this in a method - choice() which will return the number of seats available for a given category.

After you output how many seats are available, ask the user if they wish to buy a seat in that category.

If the user states "Yes", then move on to the Third Goal; If the user responds "No", then prompt them for another category. This program assumes the user will buy a seat in at least one of the categories. You can also either user the strings "Yes" and "No" or some other Boolean means to signal they have made their choice.

Third Goal:

Thank the user for their choice, confirm their choice by outputting the seat category and price they have chosen, then decrement the number of seats available in seats[ ] for that floor.

Output the seats [ ] array and the price[ ] arrays after the decrement.

You MUST use the following data to get credit:

You can hardcode and initialize the following values for your arrays:

seats[ ] = {5, 3, 1, 2} and price[ ] = {1200, 850, 600, 450}

Test your code using the following data (shown with prompt text which you can customize) which should be shown in the screenshot:

Welcome to KSU Airlines!

Please enter the amount of money you have to spend on a seat:

550

You can buy a seat in category 3.

Which category would you like to inquire about?

0

Category 0 has 5 seats available

Would you like a seat in category 0?

No

Which category would you like to inquire about?

1

Category 1 has 3 seats available

Would you like a seat in category 1?

Yes

Thank you for flying with us! You have a seat in category 1 for 850 dollars

New values for arrays:

seats[ ] = 5 2 1 2

prices[ ] = 1200 850 600 450

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Prepare a report or presentation explaining the proposed change.

Answered: 1 week ago