Water changes between solid phase as ice and liquid phase at
Water changes between solid phase (as ice) and liquid phase at UPC. and between liquid phase and gas phase (as water vapor) al 100 degree C. Write a program to accept a temperature front keyboard, and display the corresponding water phase (solid, liquid 01 gas) under that temperature.
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
public class WaterState
{
public static void main (String[] args) throws java.lang.Exception
{
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();
String state = \"liqud\";
if (temp <= 32)
state = \"solid\";
else if(temp >= 212)
state = \"gas\";
state = \" Water is \" + state;
System.out.println(state);
}
}
}
