Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a console-based Java application to help an airline customer find good ways of redeeming his/her accumulated mileage into airline tickets. Assume all trips depart

Write a console-based Java application to help an airline customer find good ways of redeeming his/her accumulated mileage into airline tickets. Assume all trips depart from O'Hare (ORD). Different destinations need different mileage for redeeming tickets. If the person doesn't travel in a busy season, he or she may take advantage of the Fly Cheap program that can attain a ticket with fewer accumulated miles.

A list of destination cities and related ticket redemption information should be read from a file, which is formatted as one city per line, with five fields separated by a semicolon ( ; ) as shown below destination; normal mileage needed for an economy class ticket (this information is proportional to the actual travel distance); Fly Cheap mileage needed for an economy class ticket; additional mileage needed for upgrading to first class; and the months of departure when the Fly Cheap mileage can be used.

For example:

Berlin;17250;12750;5250;3-5

Hong Kong;30000;20250;17500;2-4

Hyderabad;30000;20000;15000;2-4 Sidney;50000;30000;20000;5-6 Paris;20000;15000;10000;2-4 New York;10000;5000;8000;10-11

Tokyo;29000;16500;5350;2-5

Vienna;17500;12500;5000;2-4

Washington, D.C.;9000;7500;2000;10-12

Your application program should prompt the user to enter the name of the file at the keyboard. Once entered, it should be read using a Scanner object named keyScan and assigned to a String variable. Then, open another Scanner object named fileScan to read the destination lines from it. To read from an input file, you will need:

import java.io.*;

Your algorithm should 1) try to get tickets that travel the farthest, 2) use Fly Cheap mileage whenever possible, 3) try to display as many different tickets as possible given the information (at most, one ticket is needed for a single destination), and 4) use the remaining mileage for upgrade, if possible (try to upgrade the longest trip first).

Your program should first print out a list of the cities for the users information. It then loops for input and prints out tickets that can be redeemed. Accurate sample program output can be found at the end of this handout on page 4. It is recommended that you set up your output so that it looks EXACTLY like the sample provided.

Sample Accurate Program Output

Please enter the name of the file: destinations.txt

-------------------------------------------------

WELCOME TO THE JAVA AIRLINES MILES REDEMPTION APP

-------------------------------------------------

List of destination cities you can travel to:

Berlin

Hong Kong

Hyderabad

New York

Paris

Sidney

Tokyo

Vienna

Washington, D.C.

---------------------------------------------------

Please enter your accumulated Frequent Flyer Miles: 49600

Please enter your month of departure (1-12): 4

Your Frequent Flyer Miles can be used to redeem the following tickets:

* A trip to Hong Kong in Economy Class

* A trip to Hyderabad in Economy Class

* A trip to Washington, D.C., in Economy Class

Your remaining Frequent Flyer Miles: 350

Do you want to continue (y/n)? n

-----------------------------------------------------------

THANK YOU FOR USING THE JAVA AIRLINES MILES REDEMPTION APP!

-----------------------------------------------------------

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_2

Step: 3

blur-text-image_3

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions