Write a java program that asks for temperature in Fahrenheit. The program should accept any floating point number. Display whether water is liquid, solid, or gas at that temperature at sea level. Display the results like this: “Water at that temperature is a solid/liquid/gas.” (Note: display only the correct state for that temperature.) water freezes at 32 degrees F and boils at 212 degrees F.
//FahrenheitToState.java import java.util.Scanner; public class FahrenheitToState { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); float f; System.out.print("Enter temperature in Fahrenheit: "); f = scanner.nextFloat(); if(f<=32){ System.out.println("solid"); } else if(f<212){ System.out.println("liquid"); } else{ System.out.println("gas"); } } }
Get Answers For Free
Most questions answered within 1 hours.