PDA

View Full Version : problem with variables in java...



Mia_tech
March 9th, 2009, 07:58 AM
guys, I'm working on a program that has three classes and one of the classes computes a simple math operation involving variables of type double nickel = 0.05 dime = 0.10 and so on... and I'm storing all that in another variable also of type double balance, but for some reason the program is only seeing one digit after the dot like 0.0 instead of 0.05 for nickel and that screws all the calculation and decision making of the program.... I've never had this happened before.... why could this be happening?... all variable are properly initialized

PythonPower
March 9th, 2009, 10:36 AM
Post some code! How are you outputting the values?

Mia_tech
March 9th, 2009, 07:16 PM
well the methods have a return statement in which they are called from the main method with a System.out.prinln(object.method);
for some strange reason when I change those variables to constants it fixed the problem... go figure