1. Engineering
  2. Computer Science
  3. write a java program called streetajava that firstly prompts asks...

Question: write a java program called streetajava that firstly prompts asks...

Question details

Write a Java program called StreetA.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 (lines). Each record has the same format as Task 1 The input file may have 0 to any number of records. The format of the input file is guaranteed to be correct. Your program does not have to check the format. Also, your program must work with any file name of the correct format.

 

Once this file has been opened, the program checks if this file is empty (you may assume that the user always enters a valid file name). If the file is empty the program displays an appropriate message to the screen and closes, without using System.exit( ).

 

If the file is not empty, then the user is prompted (asked) to enter a road and a suburb.

 

The user entry for road and suburb must be case insensitive. That is, Brunswick Street and BRunswIcK strEET must produce the same result.

 

The program then displays to the screen all the details of Tram stops (the complete record) that match the road and the suburb, as entered by the user.

 

To do this, your program will need to read the entire contents of the file, line by line. Unlike Task 1, there may be more than one Tram stop that meets the road and suburb requirements

 

 

SAMPLE RUN

> java Street Enter file name >> a.dat Enter road name >> Brunswick Street Enter suburb >> Fitzroy "Suburb": Fitzroy "road": Brunswick Street "cross street": Gertrude Street "stop": 13 "tracker id": 1353 "Suburb": Fitzroy "road": Brunswick Street "cross street": King William Street "stop": 14 "tracker id": 1354 "Suburb": Fitzroy "road": Brunswick Street "cross street": St David Street "stop": 15 "tracker id": 1355 "Suburb": Fitzroy "road": Brunswick Street "cross street": Jonhston Street "stop": 16 "tracker id": 1356 "Suburb": Fitzroy "road": Brunswick Street "cross street": Leicester Street "stop": 17 "tracker id": 1357 > java Street Enter file name >> e.dat "e.dat" is an empty file > java Street Enter file name >> a.dat Enter road name >> Brunswick Street Enter suburb >> Reservoir No information for the requested road and suburb was found

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution