I need help with some homework code. I was asked to increment and decrement the temperature based on the increment field predifined by the user. The temperature is set to 50 by default. So, my problem is that if i set the maximum temperature to 85 and increment by 25. Once I run the warmer method below, and the temperature gets incremented to 100 (even though my IF statement is < maximum) and then it displays the error message once I run the warmer method again. I don't know why my if statement adds the value of the increment field and then displays the error message. I working with blueJ IDE.
public int warmer() { if (temperature < maximum) { temperature= increment + temperature; //return temperature; } else { System.out.println("You cannot increase above the predifined maximum temperature \n Please set maximum > " + maximum); } return temperature; }