Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 4- Task4.java Write a Java program called Task4.javathat, firstly,prompts (asks) the user to enter an input file name. This is the name of a

Task 4-

Task4.java Write a Java program called Task4.javathat, 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).

The input file may have 0 to any number of records. The format of the input file isguaranteed 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 program checks if this file is empty(you may assumethat the user always enters a valid file name). If the file is empty the program displaysan appropriate message to the screen and closes, without using System.exit( )

.If the file is not empty, there is no further user input in this Task4.

The program then displays to the screen all the details of all Airports that have no State. That is the StateString is an empty String, it just has the opening '}'immediately followed by the closing '}'. Read the top ofpage 4 again forthe output (display) of empty State Strings

.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 Task4

Enter file name >> a.dat

Code = AFS

Country = Uzbekistan

City = Zarafshan

State = No State Listed

Airport = Zarafshan Airport

Code = AQB

Country = Guatemala

City = Quiche

State = No State Listed

Airport = Quiche Airport

Code = IXM

Country = India

City = Tamil Nadu

State = No State Listed

Airport = Madurai Airport

Code = JHB

Country = Malaysia

City = Johor Bahru

State = No State Listed

Airport = Senai International Airport

Code = CHN

Country = South Korea

City = Jeonju

State = No State Listed

Airport = Jeonju Airport

> java Task4Enter file name >> x.dat

"x.dat" is an empty file, program closing

(please dont use buffert reader or Scanner class)

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions