I'm writing code to determine the state of water depending on the temperature in celsius and altitude, how can I make it so at the end, if the altitude is more than 300, it takes 1 less degree celsius for the water to boil and the outcome can be determined depending on the input?
import java.util.Scanner;
public class WaterState
{
public static void main(String[] args)
{
boolean run = true;
while(run)
{
Scanner scan = new Scanner(System.in);
System.out.println("What is the temperature in degrees Celsius?");
double temp = scan.nextDouble();
System.out.println("What is the height above Sea level? in exact meters");
double altitude = scan.nextDouble();
int freezingPoint = 0;
double alternateAltitude = temp - (altitude * 0.001);
double boilingPoint = 100;
int baseAltitude = 300;
if ((temp <= freezingPoint) && (altitude <= baseAltitude))
{
System.out.println("Water is frozen");
}
else if ((temp > freezingPoint) && (altitude <= baseAltitude))
{
System.out.println("Water is liquid");
}
else if ((temp >= boilingPoint) && (altitude <= baseAltitude))
{
System.out.println("Water is gaseus");
}
else if ((altitudeChange > )
{
System.out.println("Water is boiling, but at a lower temperature because of the altitude");
}
}
}
}
Here is what is relative to your question:
And according to your input:
Is this is what you want: