//Zachary Abdollahi CS1A Chapter 4, P. 224, #20
//
/*******************************************************************************
*
* CALCULATE FREEZING AND BOILING POINTS
*
*______________________________________________________________________________
* This program asks the user to enter a temperature and then reports which
* substances would freeze at a given temperature and which would boil at
* a given temperature.
*
* INPUT
* temperature : Temperature entered by the user (in Fahrenheit)
*
* OUTPUT
* List of substances that freeze at that temperature
* List of substances that boil at that temperature
*
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
double temperature; //INPUT - Temperature entered by the user
// Freezing and boiling points for each substance
const double ETHYL_FREEZE = -173.0;
const double ETHYL_BOIL = 172.0;
const double MERCURY_FREEZE = -38.0;
const double MERCURY_BOIL = 676.0;
const double OXYGEN_FREEZE = -362.0;
const double OXYGEN_BOIL = -306.0;
const double WATER_FREEZE = 32.0;
const double WATER_BOIL = 212.0;
// Get input from user
cout << "Enter a temperature (in Fahrenheit): ";
cin >> temperature;
// Check which substances freeze at this temperature
cout << "\nAt " << temperature << " degrees, the following will freeze:" << endl;
if (temperature <= ETHYL_FREEZE)
cout << "Ethyl alcohol" << endl;
if (temperature <= MERCURY_FREEZE)
cout << "Mercury" << endl;
if (temperature <= OXYGEN_FREEZE)
cout << "Oxygen" << endl;
if (temperature <= WATER_FREEZE)
cout << "Water" << endl;
// Check which substances boil at this temperature
cout << "\nAt " << temperature << " degrees, the following will boil:" << endl;
if (temperature >= ETHYL_BOIL)
cout << "Ethyl alcohol" << endl;
if (temperature >= MERCURY_BOIL)
cout << "Mecury" << endl;
if (temperature >= OXYGEN_BOIL)
cout << "Oxygen" << endl;
if (temperature >= WATER_BOIL)
cout << "Water" << endl;
return 0;
}