Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to figure out this Java word problem by tomorrow morning and I would really appreciate some guidance. In a communication network, a number

I have to figure out this Java word problem by tomorrow morning and I would really appreciate some guidance.

In a communication network, a number of towers are placed strategically for transmission purposes. Each of these towers has an effective range (or radius covered) of, say, 5 km. In order to have good reception of the signal, and to ensure one would not be disconnected in case of failure of one of the towers, it is recommended to be in a location covered by at least two towers. Your job is to check that each of the locations provided are indeed covered by at least two towers. Note: in order to be covered by a tower, the direct distance between the location and the tower must be smaller than 5. As a reminder, here is the formula to calculate the distance between two points (one at coordinates and one at coordinates ): sqrt[(x1-x2)^2 + (y1-y2)^2]

INPUT:

You should read your input from the file dataAsgn7.txt. The input file begins with a single line containing N, a positive whole number that indicates the number of towers. Then there are N lines. Each consists of the coordinates of each of those towers, as 2 positive whole numbers separated by a space: the X coordinate, then the Y coordinate. This is followed by an empty line, and then a positive whole number M (on a single line) indicating the number of locations to be checked. There are then M lines. Each consists of the coordinates of each of these locations (again, as 2 positive whole numbers separated by a space: X coordinate, then Y coordinate).

OUTPUT:

You should print on the screen the index of the locations that are not properly covered (the first location in the input file having an index of 1, the second one having an index of 2, and so on). There should be one index per line. You can assume that there will always be at least one location not properly covered. The indexes should be displayed in ascending order.

HINT: You will need 2 arrays of integers to store the coordinates of the towers...

SAMPLE INPUT AND OUTPUT:

For the example below, the first locatoin is properly covered, as it is clearly within a distance of 5 of both the towers 1 and 3. Howeccer, the second location is not properly covered because it is within the range of tower 3 only. The third location is way out of range of any of the towers.

EXAMPLE INPUT (file provided to you):

3

5 3

2 8

6 9

3

5 6

8 1

30 9

EXAMPLE OUTPUT:

2

3

and "dataAsgn7.txt" is:

3 5 3 2 8 6 9

3 5 6 8 11 30 9

Any nudge in the right direction will be greatly appreciated!

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

Build active verb-based sentences

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago