The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Writing a Java program and I need help!!!

Posted by Redden on October 30, 2000 at 8:45 PM

Hi, I'm coding a java program and I'm having some small problems.
Basically the program is supposed to do the following:

Create a pitcher and three goblets (by prompting the user for the initial contents of each container, and then constructing the required objects). For this application, the values for the contents of the pitcher and one goblet will be greater than zero, but the values for the contents of the other two goblets will be zero.
---this much I've done no problem

The task is then to equalize the contents of the goblets. This will be accomplished as follows:

If there is sufficient liquid in the pitcher to bring the two goblets with zero contents to the level of the goblet with non-zero contents, then this is what will be done.
Otherwise, the fluid from the goblet will be poured into the pitcher, and the contents of the pitcher will be divided "equally" among the three goblets.
Note: If the contents of the pitcher is not divisible by 3, this cannot be done exactly, since the contents of the objects are recorded to two decimal places. However, we do not want a tiny amount of liquid left in the pitcher! So, the pitcher should be emptied into the third goblet, even if that means that the third goblet will have a bit more liquid in it.
----this is where it gets sticky for me! If you can help me email me redux@chickmail.com!!!!!! I have some parts like:

firstGoblet.pourInto(gAmount, firstPitcher);
equalize = (firstPitcher.getAmount()/3);
//round the equalizing amount to two decimal places, and then print this value onscreen
equalizeRounded = (int)(equalize * 100);
System.out.println("the equalized amount is: " + equalizeRounded/100);

But I'm missing stuff.
Thanks!!!!!!!! (I can give the needed classes Pitcher.class and Goblet.class)



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us