1. Declare a file pointer called input. Open a file called location.txt for reading using this pointer. 2. If the file is not available, display “File does not exist. ". 3. The content of the text file location.txt is as shown below. It includes the location, latitude and longitude values. FILE location.txt CONTENTS UTM 1.5523763 103.63322 KLCC 3.153889 101.71333 UM 3.1185 101.665 UMS 6.0367 116.1186 UNIMAS 1.465174 110.4270601 Ask the user to enter a location. Check if the user's location can be found in the text file. If found, display the location, latitude and longitude as shown below. SAMPLE OUTPUT Enter a location: UM : UM : 3.1185 : 101.6650 Location Latitude Longitude Otherwise display “Sorry, location could not be found". SAMPLE OUTPUT Enter a location : MMU Sorry, location could not be found

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
1. Declare a file pointer called input. Open a file called location.txt for reading using this
pointer.
2. If the file is not available, display “File does not exist. ".
3. The content of the text file location.txt is as shown below. It includes the location, latitude
and longitude values.
FILE location.txt CONTENTS
<Location> <Latitude> <Longitude>
UTM 1.5523763 103.63322
KLCC 3.153889 101.71333
UM 3.1185 101.665
UMS 6.0367 116.1186
UNIMAS 1.465174 110.4270601
Ask the user to enter a location. Check if the user's location can be found in the text file. If found,
display the location, latitude and longitude as shown below.
SAMPLE OUTPUT
Enter a location: UM
: UM
: 3.1185
: 101.6650
Location
Latitude
Longitude
Otherwise display “Sorry, location could not be found".
SAMPLE OUTPUT
Enter a location : MMU
Sorry, location could not be found
Transcribed Image Text:1. Declare a file pointer called input. Open a file called location.txt for reading using this pointer. 2. If the file is not available, display “File does not exist. ". 3. The content of the text file location.txt is as shown below. It includes the location, latitude and longitude values. FILE location.txt CONTENTS <Location> <Latitude> <Longitude> UTM 1.5523763 103.63322 KLCC 3.153889 101.71333 UM 3.1185 101.665 UMS 6.0367 116.1186 UNIMAS 1.465174 110.4270601 Ask the user to enter a location. Check if the user's location can be found in the text file. If found, display the location, latitude and longitude as shown below. SAMPLE OUTPUT Enter a location: UM : UM : 3.1185 : 101.6650 Location Latitude Longitude Otherwise display “Sorry, location could not be found". SAMPLE OUTPUT Enter a location : MMU Sorry, location could not be found
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,