COMP1405 - Assignment #2: (1) Cell Phone Usage
COMP1405 - Assignment #2: (1) Cell Phone Usage
return
the range as an integer obtained from the
user.
The main program should call this function
4 times to get the information from the user and then it should then display a message indicating whether
or not you can travel from city 1 to city 2 to city 3 and finally to city 4 without losing cell phone service
along the way.
You may say something like "Cell phone service will become unavailable" or "Cell phone service
will remain available". In order to determine whether or not cell service is lost along the way, you will
need to make sure that the circle around city1 overlaps with the circle around city2, and that city2's circle
overlaps with city 3's circle, etc... So, the distance between two adjacent city centers must be less than
the sum of the two city ranges in order for the cell phone service not to be lost You must also create a
static function called distance() that will calculate the distance between two cities as follows:
distance = the square root of ((Xb - Xa)2 + (Yb - Ya)2) where the cities have coordinates
(Xa,Ya) and (Xb,Yb), respectively.
Make sure to test your code with the different city cell phone ranges shown in the following table:
Range 1
85
85
80
65
Range 2
75
75
80
75
Range 3
115
50
80
75
Range 4
65
65
80
125
Answer
remains available
becomes unavailable
remains available
becomes unavailable
(yes or no)
? (yes or no)
? (yes or no)
? (yes or no)
NOTE: Submit a zipped file (not RAR) of a folder called Ass2 which contains all of your .java files (i.e., not .class files).
Submit your assignment using CULearn. Note that if your internet connection at home is down or does not work, we will not
accept this as a reason for handing in an assignment late ... so make sure to submit the assignment WELL BEFORE it is due !
Please NOTE that you WILL lose marks on this assignment if any of your files are missing. You
may also lose marks if your code is not written neatly with proper indentation. See examples in
the notes for proper style.