Skip to content
Advertisement

Subtraction loops in java

I am new to java and am stuck on this challenge. I am to calculate the state of water depending on the inputed temp and altitude. However, for every 300 metres (for altitude) the boiling point is to drop by 1 degree. I am confused as to how to make it a loop that will take one off for every three hundred rather than just removing one when it hits three hundred. This is what I have so far. EDIT: Thank you so much for the help! Didn’t even know if people used this website anymore but now I will use it all the time lol 😀

JavaScript

Advertisement

Answer

Why do you think a loop is needed to calculate the boiling point? Think about it: given an altitude, return the boiling point of water. You can actually calculate the melting and boiling points with this info and then just check in which range you fall in.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement