Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java on Android Studio, I have two locations from the map and their coordinates. I need to find the time the user has been

In Java on Android Studio, I have two locations from the map and their coordinates. I need to find the time the user has been traveling between the two locations. I have the following method to calculate time. Is this method right or how can I make it better? If it is wrong, how can I modify the code to give the approximate time?

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; if (totalMinutes<60) { return ""+totalMinutes+" mins"; }else { String minutes = Integer.toString(totalMinutes % 60); minutes = minutes.length() == 1 ? "0" + minutes : minutes; return (totalMinutes / 60) + " hour " + minutes +"mins"; } }

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Find the derivative of the following functions. f(x) x + 1

Answered: 1 week ago

Question

=+How should we organize a book to maximize learning and interest

Answered: 1 week ago