The following table lists the freezing and boiling points of several substances
ID: 3643468 • Letter: T
Question
The following table lists the freezing and boiling points of several substances in Fahrenheit.Substance Freezing Point Boiling Point
Ethyl Alcohol 2173 172
Oxygen 2362 2306
Water 32 212
Design a class that stores a temperature in a temperature field and has the appropriate
accessor and mutator methods for the field. The class should also have the following
methods:
? isEthylFreezing . This method should return the boolean value true if the tempera-
ture stored in the temperature field is at or below the freezing point of ethyl alcohol.
Otherwise, the method should return false .
? isEthylBoiling . This method should return the boolean value true if the tempera-
ture stored in the temperature field is at or above the boiling point of ethyl alcohol.
Otherwise, the method should return false .
? isOxygenFreezing . This method should return the boolean value true if the tem-
perature stored in the temperature field is at or below the freezing point of oxygen.
Otherwise, the method should return false .
? isOxygenBoiling . This method should return the boolean value true if the temper-
ature stored in the temperature field is at or above the boiling point of oxygen.
Otherwise, the method should return false .
? isWaterFreezing . This method should return the boolean value true if the temperature
stored in the temperature field is at or below the freezing point of water. Otherwise,
the method should return false .
? isWaterBoiling . This method should return the boolean value true if the temperature
stored in the temperature field is at or above the boiling point of water. Otherwise,
the method should return false .
Write a program that demonstrates the class. The program should ask the user to enter a
temperature, and then display a list of the substances that will freeze at that temperature
and those that will boil at that temperature. For example, if the temperature is 220, the
class should report that water will freeze and oxygen will boil at that temperature.
Explanation / Answer
please rate
import java.util.Scanner;
public class FreezingBoiling {
/*
* Ethyl Alcohol 2173 172
* Oxygen 2362 2306
* Water 32 212
*/
int temperature;
int ethylBoiling = 172;
int oxygenBoiling = 2306;
int waterBoiling = 212;
int ethylFreezing = 2173;
int oxygenFreezing = 2362;
int waterFreezing = 32;
public boolean isEthylFreezing(){
return ( temperature < ethylFreezing );
}
public boolean isEthylBoiling(){
return ( temperature >= ethylBoiling );
}
public boolean isOxygenFreezing(){
return ( temperature < oxygenFreezing );
}
public boolean isOxygenBoiling(){
return ( temperature >= oxygenBoiling );
}
public boolean isWaterFreezing(){
return ( temperature < waterFreezing );
}
public boolean isWaterBoiling(){
return ( temperature >= waterFreezing );
}
public FreezingBoiling(int temperature) {
this.temperature = temperature;
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the temperature of substance: ");
int temperature = input.nextInt();
FreezingBoiling fb = new FreezingBoiling(temperature);
System.out.println("Is ethyl freezing point? "+fb.isEthylFreezing());
System.out.println("Is ethyl boiling point? "+fb.isEthylBoiling());
System.out.println("Is oxygen freezing point? "+fb.isOxygenFreezing());
System.out.println("Is oxygen boilinging point? "+fb.isOxygenBoiling());
System.out.println("Is water freezing point? "+fb.isWaterFreezing());
System.out.println("Is water boiling point? "+fb.isWaterBoiling());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.