This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes Puzzle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Puzzle" Watch "Puzzle" New topic
Author

Puzzle

Nilesh Parikh
Ranch Hand

Joined: Mar 14, 2000
Posts: 52
Hey All
I have a 5 Gallon and 3 gallon Water Containers and Lots of Water. How do I measure exaclty 4 Gallons of water. THe containers are not marked and I dont have any other Containers.
Alkesh
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
1. Fill the 3-gallon water container and pour it into the 5-gallon water container.
2. Fill the 3-gallon water container and pour it into the 5-gallon water container which already contains 3 gallons of water. This leaves 1 gallon of water in the 3-gallon water container.
3. Empty the 5-gallon water container and then add the 1 gallon of water from the 3-gallon container.
4. Fill the 3-gallon water container and add it to the 1 gallon of water in the 5-gallon container. Presto - 4 gallons of water!
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
I'm going to move this to Programming Diversions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Puzzle
 
Similar Threads
Simple Question
Java Questions in Interview
Omnivore's Dilemma
which are you?
long to Integer conversion