# How do I make the integer go below 0 and become negative instead of staying at 0?

• 09-13-2012, 10:17 PM
How do I make the integer go below 0 and become negative instead of staying at 0?
Instead of having 0 I want to have -100 as my output, how do I get this to work.

public class BalloonTester {

public static void main (String[] args)
{
String one;
String two;

one = "One";
two = "Two";

Balloon balloonOne = new Balloon(one,100);

Balloon balloonTwo = new Balloon(two,(-100));

String nameOfBalloonOne;
double altitudeOfBalloonOne;

nameOfBalloonOne = balloonOne.getName();
altitudeOfBalloonOne = balloonOne.getAltitude();

System.out.println("The name of the first balloon is " + nameOfBalloonOne +
" and the altitude of the balloon is " + altitudeOfBalloonOne);

String nameOfBalloonTwo;
double altitudeOfBalloonTwo;

nameOfBalloonTwo = balloonTwo.getName();
altitudeOfBalloonTwo = balloonTwo.getAltitude();

System.out.println("The name of the second balloon is " + nameOfBalloonTwo +
" and the altitude of the balloon is " + altitudeOfBalloonTwo);

__________________________________________________ _______

The name of the first balloon is One and the altitude of the balloon is 100.0
The name of the second balloon is Two and the altitude of the balloon is 0.0
• 09-13-2012, 11:06 PM
Zyril
Re: How do I make the integer go below 0 and become negative instead of staying at 0?
Also, post relevant code, in this case the Balloon class.

Third, why are you declaring the variables on separate lines instead of in one line?
A more efficient way is this:
Code:

`String nameOfBalloonOne = balloonOne.getName();`
• 09-13-2012, 11:17 PM
DarrylBurke
Re: How do I make the integer go below 0 and become negative instead of staying at 0?
`altitude = Math.max(theAltitude, 0);`