File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programming Diversions and the fly likes Distance problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Distance problem" Watch "Distance problem" New topic
Author

Distance problem

Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
A software engineer just returned from US has eaten too much fat and put a lot of weight every sunday he starts walking 4 km/hr on level
ground then up at 3 km\hr then back down hill at 6km\hr then again
on level grounggd at 4km\hr till he reaches his destination if he
returned home at 9 p.m. e what is the distance did he covered ?
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
Originally posted by Sameer Jamal:
A software engineer just returned from US has eaten too much fat and put a lot of weight every sunday he starts walking 4 km/hr on level
ground then up at 3 km\hr then back down hill at 6km\hr then again
on level grounggd at 4km\hr till he reaches his destination if he
returned home at 9 p.m. e what is the distance did he covered ?


I think you're missing some information needed to solve the problem.

If he starts at 9 a.m., then he covers quite a bit more ground in that 12 hours than if he starts at 8 p.m.

HOWEVER, I think the "trick" you're hoping we'll find is that the length of road on the hill is irrelevant. Let's say the hill road is 6km long. It would take him (6km)/(3km/hr)=2 hours to walk up the hill and (6km)/(6km/hr)=1 hour to walk back down. This gives an overall hill walking speed of (12km)/(1hr+2hr) = 4 km/hr. Since this is the same speed he walks on level ground, we can just pretend he walks 4 km/hr the whole way. If he starts at 8 p.m., then he goes 4 km.
jack rabbeet
Greenhorn

Joined: Nov 30, 2005
Posts: 1
What you have:
1. Ave speed 4+3+6/3 = 4.333333.. Km/h.
2. End time = 21:00
3. Start time = 00:00
4. Total time = 21:00

Answer:
21 * 4.33333333... +- = 90.99999.. KM
Ryan McGuire
Ranch Hand

Joined: Feb 18, 2005
Posts: 1010
    
    3
Jack, you can't just average speeds like that without knowing the relative distance and/or time travelled at each speed.

Let's take a simplified version of the problem. Let's say our hypothetical engineer just walked uphill at 3km/hr and downhill back home at 6km/hr. If he walked for one hour at each of these speeds, then it makes sense to to say he walked at an average speed of (3+6)/2=4.5 km/hr for the whole trip. Notice that during this trip he would go up 3 km and down 6. That would put him 3 km below his starting point.

However, there is nothing in the original problem that says he walked at 3 and 6 km/hr for the same amount of time. In fact, in order to get back home it's more likely that he walked the same distance in each direction. If the hill road is 6 km, then he walked uphill at 3km/hr for 2 hours and then downhill at 6 km/hr for 1 hour. In that case, his average speed isn't (3+6)/2. The correct formula would be (2hr*3km/hr + 1hr*6km/hr)/(1hr+2hr) = 4 km/hr.

Sameer's original problem looks a little more complicated because he doesn't give the relative lengths of the level road and the hill road. However, our walker's average speed on the hill (assuming the same distance uphill and downhill) is the same as his speed on level ground, so the relative distances are unimportant. If the walker started at midnight, giving him a total walking time of 21 hours, then he travelled 21*4 = 84 km. Regardless of his starting time, his average speed is 4, not 4 1/3 km/hr.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Distance problem