Question: java code Assume each city is located in an integer - pair ( x , y ) valued location within a 2 5 x 2

java code
Assume each city is located in an integer-pair (x, y) valued location
within a 25 x 25 square mile area. For example, a city can be located at
(4,19), but not at (4.5,19.8). In other words, there are no real valued
coordinate for a location of a city.
Your program will consider each integer-pair valued location within the area
as a possible site for the nuclear plant, starting at (1,1) and continuing
across each row until the final site (25,25) is reached.
At each possible location for the nuclear plant, your program will compute
the average unhappiness if the plant were located there. The following two
rules will be used to compute the unhappiness for a city.
1) If the plant is within two miles or less of a city, the
unhappiness is infinite (that is, assign a very large number
to the unhappiness for that city).
2) Otherwise, the unhappiness is equal to the population of the
city divided by the distance of the plant from the city.
The average unhappiness equals:
Avg. Unhappiness = Sum of the unhappiness of 4 cities /
The total state's population.
Your program should select the site at which the average unhappiness is
smallest.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!