// Chapter 4 - Programming Challenge #20
// Freezing and Boiling Points
// This program asks the user to enter a temperature
// in degrees Fahrenheit. It then determines which
// substances will freeze and which substances will
// boil at that temperature.
#include <iostream>
using namespace std;
int main()
{
// Constants for the freezing points of each substance
const double ETHYL_FREEZING = -173;
const double MERCURY_FREEZING = -38;
const double OXYGEN_FREEZING = -362;
const double WATER_FREEZING = 32;
// Constants for the boiling points of each substance
const double ETHYL_BOILING = 172;
const double MERCURY_BOILING = 676;
const double OXYGEN_BOILING = -306;
const double WATER_BOILING = 212;
// Variable to store the temperature entered by the user
double temperature;
// Get the temperature from the user
cout << "Enter a temperature in degrees Fahrenheit: ";
cin >> temperature;
// Check which substances will freeze at this temperature.
// A substance will freeze if the temperature is at or
// below its freezing point.
if (temperature <= ETHYL_FREEZING)
{
cout << "Ethyl alcohol will freeze." << endl;
}
if (temperature <= MERCURY_FREEZING)
{
cout << "Mercury will freeze." << endl;
}
if (temperature <= OXYGEN_FREEZING)
{
cout << "Oxygen will freeze." << endl;
}
if (temperature <= WATER_FREEZING)
{
cout << "Water will freeze." << endl;
}
// Check which substances will boil at this temperature.
// A substance will boil if the temperature is at or
// above its boiling point.
if (temperature >= ETHYL_BOILING)
{
cout << "Ethyl alcohol will boil." << endl;
}
if (temperature >= MERCURY_BOILING)
{
cout << "Mercury will boil." << endl;
}
if (temperature >= OXYGEN_BOILING)
{
cout << "Oxygen will boil." << endl;
}
if (temperature >= WATER_BOILING)
{
cout << "Water will boil." << endl;
}
return 0;
}