Java I';我正在编写代码,用if语句确定水的状态

Java I';我正在编写代码,用if语句确定水的状态,java,if-statement,logic,java.util.scanner,temperature,Java,If Statement,Logic,Java.util.scanner,Temperature,我正在编写代码,根据摄氏温度和海拔高度来确定水的状态,我如何才能做到这一点,如果海拔高度超过300,水沸腾所需的温度就会降低1摄氏度,结果可以根据输入来确定 import java.util.Scanner; public class WaterState { public static void main(String[] args) { boolean run = true; while(run) {

我正在编写代码,根据摄氏温度和海拔高度来确定水的状态,我如何才能做到这一点,如果海拔高度超过300,水沸腾所需的温度就会降低1摄氏度,结果可以根据输入来确定

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");

        }
    }
}
}
import java.util.Scanner;
公共级水务州
{       
公共静态void main(字符串[]args)
{
布尔运行=真;
while(运行)
{
扫描仪扫描=新扫描仪(System.in);
System.out.println(“以摄氏度为单位的温度是多少?”);
double temp=scan.nextDouble();
System.out.println(“海平面以上的高度是多少?以米为单位”);
双高度=scan.nextDouble();
int freezingPoint=0;
双交替温度=温度-(高度*0.001);
双沸点=100;
国际基准高度=300;

如果((温度以下是与您的问题相关的内容:

        else if ((altitudeChange > ){ 
            System.out.println("Water is boiling, but at a lower temperature because of the altitude");
        }
根据您的输入:

如果海拔高度超过300度,则需要少1摄氏度的温度 煮沸的水和结果取决于温度 输入

这就是你想要的:

if(altitude >=baseAltitude  && temp>(boilingPoint -(altitude/baseAltitude *1)) ){//1.altitude is more than 300,2.temp is higher than the new degree celsius to boil 
 System.out.println("Water is boiling, but at a lower temperature because of the altitude");
}

我不确定我是否准确地回答了这个问题,但我猜您正在寻找类似于
if(海拔>300&&temp>=沸点-1)
的东西,如果海拔>基准海拔,只需更改沸点即可。@hover craftfullofels,但确实没有人根据问题的“紧迫性”回答问题,我不认为这对任何人都是不公平的。它只是一片空白。@OlaviMustanoja:不管怎样,1)我提供信息以帮助他们在未来的问题上,2)我给了他答案,3)否决票不是我的。@Hoverskifullofeels我没有对你的第1、2或3点发表任何评论