Compose a class and, in this class, create two static methods: A method called getWaterState, which takes
Question:
Compose a class and, in this class, create two static methods:
A method called getWaterState, which takes a single integer parameter called temperature and returns a String.
The method should return a single word identifying the state of water at different temperatures in 0F. Use the following rules:
- Under 320F, the water is ice.
- Above 320F but under 2120F, the water is liquid.
- Above 2120F, the water is vapor.
- At exactly 320F or 2120F, the water is freezing or boiling, respectively.
A main method to demonstrate your getWaterState method; use it to print the statements below at the given temperatures.
Sample output:
For temperatures 0, 32, 80, 212, 240:
The state of water at 0 degrees Fahrenheit is ice. The state of water at 32 degrees Fahrenheit is freezing. The state of water at 80 degrees Fahrenheit is liquid. The state of water at 212 degrees Fahrenheit is boiling. The state of water at 240 degrees Fahrenheit is vapor.
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch