Task 1 – Codes.java (after you read the whole assignment )Write a Java program called Codes.java that, firstly, prompts (asks) the user to enter aninput file name. This is the name of a text f
Task 1 – Codes.java (after you read the whole assignment )Write a Java program called Codes.java that, firstly, prompts (asks) the user to enter aninput file name. This is the name of a text f
Task 1 – Codes.java (after you read the whole assignment )
Write a Java program called Codes.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:
Station code#Station name#date built
where:
Station code is a 3 character code that identifies the station. This code is
unique and is followed by a '#' character, there are no spaces between the '#'
and the Station name and the code is always in uppercase characters.
Station name is the unique name of a railway station. This is a String (text) and
may contain more than one word. This name is followed by a '#' character, there
are no spaces after the '#'.
date built is the date that the station was built. The date is always in the
format
[d]d month yyyy
where:
[d]d is the day, if the day is less than 10 then there will only be one digit
if the date is greater than or equal to 10 then there will be 2 digits
The [d] indicates that this digit may or may not be present
The d indicates that this digit must be present
month is the (text) name of the month, spelt in full
yyyy is the year, always 4 digits
An example of some of the lines of this file might be:
BOX#Box Hill#29 April 1983
RES#Reservoir#8 October 1889
WIN#windsor#19 December 1859
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.
(Do not hard code the file name.)
Once this file has been opened, the user is then prompted for a station code.
The program then reads through the file. If a matching station code is found in the file,
all the information for that station is displayed to the screen. The order of display is shown in
the example runs below. Note that the information from the file must be enclosed in " ",
except the date.
Station codes are unique in the file, so there will be at most only one match.
OOF Assignment Part A - due: 10:00 am Mon 22nd Aug this is the first and final hand in date p. 5 of 13
User entered Station codes 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.
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 Codes
Enter file name >> stationsMaster.txt
Enter station code >> PRE
Station name: "Preston" has code "PRE" date built: 8 October 1889
> java Codes
Enter file name >> stationsMaster.txt
Enter station code >> ABC
No station with the code "ABC" was found
> java Codes