Question

Write a java program that asks for temperature in Fahrenheit. The program should accept any floating...

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.

Homework Answers

Answer #1
//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");
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Program must be in JAVA. Write a program that converts temperature from Celsius to Fahrenheit or...
Program must be in JAVA. Write a program that converts temperature from Celsius to Fahrenheit or vice versa, depending on user's input. The formula for converting temperature in Celsius to Fahrenheit is, Fahrenheit = (9/5) * Celsius + 32 The formula for converting temperature in Fahrenheit to Celsius is, Celsius = (5/9) * (Fahrenheit – 32) Results should be rounded to two decimal points, e.g., 92.56
Find an equation of the line that gives the relationship between the temperature in degrees Celsius...
Find an equation of the line that gives the relationship between the temperature in degrees Celsius C and the temperature in degrees Fahrenheit F. Remember that water freezes at 0 Celsius (32 Fahrenheit) and boils at 100 Celsius (212 Fahrenheit).
Water freezes at 0 degrees Celsius, which is the same as 32 degrees Fahrenheit. Also water...
Water freezes at 0 degrees Celsius, which is the same as 32 degrees Fahrenheit. Also water boils at 100 degrees Celsius, which is the same as 212 degrees Fahrenheit. (Use fractions in your answers.) (a) Use the freezing and boiling points of water to find a formula expressing Celsius temperature C as a linear function of the Fahrenheit temperature F. (b)This means that for every one degree increase in the Fahrenheit temperature, the Celsius temperature will increase by what degree?
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale conversion he/she would like to perform: 1. Convert F to C 2. Convert C to F 3. Quit What is your choice? Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the...
Write a Java program that asks the user to enter a person’s age. Then the program...
Write a Java program that asks the user to enter a person’s age. Then the program should display text indicating whether the person is an infant, a toddler, a child, a teenager, an adult, or a senior. It should display it just like this: “This person’s age category: x”, where x is the person’s age category based on the following guidelines: If less than 1 year old, the person is an infant. If at least 1 year old but younger...
(1)You work in a materials testing lab and your boss tells you to increase the temperature...
(1)You work in a materials testing lab and your boss tells you to increase the temperature of a sample by 45.2 ∘C . The only thermometer you can find at your workbench reads in degrees Fahrenheit. Part A If the initial temperature of the sample is 66.8 ∘F, what is its temperature in degrees Fahrenheit when the desired temperature increase has been achieved? (2) Like the Kelvin scale, the Rankine scale is an absolute temperature scale: Absolute zero is zero...
Write a program in java that generates a two-column table showing Fahrenheit temperatures from -40F to...
Write a program in java that generates a two-column table showing Fahrenheit temperatures from -40F to 120F and their equivalent Celsius temperatures. Each line in the table should be 5 degrees F more than the previous one. Both the Fahrenheit and Celsius temperatures should be accurate to 1 decimal place. I am not able to use: import java.text.DecimalFormat; Any feedback would be helpful.
Objective: Write a Java program that will use a JComboBox from which the user will select...
Objective: Write a Java program that will use a JComboBox from which the user will select to convert a temperature from either Celsius to Fahrenheit, or Fahrenheit to Celsius. The user will enter a temperature in a text field from which the conversion calculation will be made. The converted temperature will be displayed in an uneditable text field with an appropriate label. Specifications Structure your file name and class name on the following pattern: The first three letters of your...
In one C++ program: a.) Write a code to asks the user for her/his full name...
In one C++ program: a.) Write a code to asks the user for her/his full name b.) Write a code that asks the user to enter information related to a car the user likes (year, make, model) c.) Write a code that asks the user to enter the amount of time or gas or money the user spends to commute weekly d.) Write a code that asks the user to enter the number Kwh (used monthly) and compute the user...
In c++ format please Most people know that the average human body temperature is 98.6 Fahrenheit...
In c++ format please Most people know that the average human body temperature is 98.6 Fahrenheit (F). However, body temperatures can reach extreme levels, at which point the person will likely become unconscious (or worse). Those extremes are below 86 F and above 106 F. Write a program that asks the user for a body temperature in Fahrenheit (decimals are ok). Check if that temperature is in the danger zone (for unconsciousness) or not and produce the relevant output shown...