//Cameron Pham CS1A Chapter 4, P. 224, #20
//
/*******************************************************************************
*
* Calculate Freezing and Boiling Points
*
*______________________________________________________________________________
* This program accepts a value for temperature and then determines which
* substances would freeze at a given temperature and which would boil at
* a given temperature.
*
* INPUT
* Temperature in Fahrenheit
*
* OUTPUT
* List of substances that freeze at given temperature
* List of substances that boil at given 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;
cout << endl;
cout << "You entered " << temperature << "." << endl;
// Check which substances freeze at this temperature
cout << "\nAt " << temperature << " degrees, the following will freeze:";
cout << 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:";
cout << 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;
}