Answered step by step
Verified Expert Solution
Question
1 Approved Answer
On Android Studio in Java, I have two locations from the map and their corrisponding coordinates. I need to find the appoximate amount of time
On Android Studio in Java, I have two locations from the map and their corrisponding coordinates. I need to find the appoximate amount of time in minutes that the user has been traveling between the two locations. I have the following method to calculate time. This method, however, gives a large amount of time when the second location is several hours away from the first location. Hence, I think that the math behind it is wrong. How can I fix this method to give me the right approximate time between two Locations and what is that code?
public String getTimeTaken(Location source, Location dest) { double meter = source.distanceTo(dest); double kms = meter / 1000; double kms_per_min = 0.5; double mins_taken = kms / kms_per_min; int totalMinutes = (int) mins_taken; String a = totalMinutes + " minutes"; return a; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started