Question: Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input file name. This is the name of a text
Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input file name. This is the name of a text file that can contain any number of records. A record in this file is a single line of text in the following format: Num of passengers^range^name^manufacturer^model
where:
Num of passengers is the total number of people in the plane. This represents an integer number, but remember that it is still part of the String so each "digit" is actually a character. It is not an integer until it is extracted from the String and converted into an actual integer. The Num of passengers is followed by a '^' character, there are no spaces before or after the '^'.
range is the range, in kilometres, of the plane. This represents an integer number, but remember that it is still part of the String so each "digit" is actually a character. It is not an integer until it is extracted from the String and converted into an actual integer. The range is followed by a '^' character, there are no spaces before or after the '^'.
name, is the name of plane. This is a String (text) and may have spaces in it. The name may be empty as not all planes have "names". The name is followed by a '^' character, there are no spaces before or after the '^'.
manufacturer, is the name of the company that makes the plane. This is a String (text) and may have spaces in it. The manufacturer is followed by a '^' character, there are no spaces before or after the '^'.
model, is the name of the model of the plane. This is a String (text) and may have spaces in it. The model is the end of the String, there is only a newline character (not seen) after model, as this is the end of the line.
An example of some of the lines of this file might be: 1^835^Butcher Bird^Focke-Wulf^Fw 190 853^15700^^Airbus^A380-800 10^3200^Flying Fortress^Boeing^B17-G
Once this file has been opened, the user is then prompted (asked) for a manufacturer and a model. The program then reads through the file. If a matching manufacturer and model is found in the file, all the information for that plane is displayed to the screen. The order of display is shown in the example runs below.
Manufacturer's can be repeated in the file, but, the combination of manufacturer AND model is unique in the file, so there will be at most only one match.
User entered manufacturer's and model's must be case insensitive, that is, any combination of uppercase and lowercase letters must give the same result.
If the entire contents of the file has been read and no match is found, then an appropriate message is displayed to the screen. The data is surrounded by " ". Output is on one line, even though it is shown wrapped around, just to fit on this page.
Some sample runs of the program are included below (user input is in bold): (Note that the sample runs do not necessarily show all the functionality required)
> java Flying
Enter file name >> planes.dat Enter manufacturer >> Sukhoi Enter model >> Su-27 Name: "Flanker" model: "Su-27" manufacturer: "Sukhoi" range: "3530kms" passengers: "1"
> java Flying
Enter file name >> planes.dat Enter manufacturer >> Focke-Wulf Enter model >> Ta-152 No plane with the model "Ta-152" made by the manufacturer "Focke-Wulf" was found
> java Flying
Enter file name >> e.dat The file "e.dat" is an empty file, program closing
An example input file for all Tasks may be copied from the csilib area
cp /home/student/csilib/cse1oof/assignA/a.dat .
cp /home/student/csilib/cse1oof/assignA/f.dat .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
