CREATE A FreezerBoil class and a Subtances class The following table lists the f
ID: 3543294 • Letter: C
Question
CREATE A FreezerBoil class and a Subtances class
The following table lists the freezing and boiling points of several substances in Fahrenheit.
Substance Freezing Point Boiling Point
Ethyl Alcohol freezing: -173 Boiling: -172
Oxygen freezing: -362 Boiling: -306
Water freezing 32 Boiling: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.
USE THE FOLLOWING TEMPERATURES : 65, -264, -43
Explanation / Answer
import java.util.Scanner;
public class FreezerBoil
{
static int alfree=-173;
static int alboi=-172;
static int oxfree=-362;
static int oxboi=-306;
static int watfree=32;
static int watboi=212;
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
System.out.println("Please enter the temperature");
double temp=in.nextDouble();
System.out.println("Ethyl Freezing:"+isEthylFreezing(temp)+" ");
System.out.println("water Freezing:"+isWaterFreezing(temp)+" ");
System.out.println("Oxygen Freezing:"+isOxygenFreezing(temp)+" ");
System.out.println("Ethyl Boiling:"+isEthylBoiling(temp)+" ");
System.out.println("Water Boiling:"+isWaterBoiling(temp)+" ");
System.out.println("Oxygen Boiling:"+isOxygenBoiling(temp)+" ");
}
public static boolean isEthylFreezing(double temp)
{
if(temp<=alfree)
return true;
else return false;
}
public static boolean isOxygenFreezing(double temp)
{
if(temp<=oxfree)
return true;
else return false;
}
public static boolean isWaterFreezing(double temp)
{
if(temp<=watfree)
return true;
else return false;
}
public static boolean isWaterBoiling(double temp)
{
if(temp>=watboi)
return true;
else return false;
}
public static boolean isEthylBoiling(double temp)
{
if(temp>=watboi)
return true;
else return false;
}
public static boolean isOxygenBoiling(double temp)
{
if(temp>=watboi)
return true;
else return false;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.