//Jeremy Huang CS1A Chapter 4, P. 224, #20
//
/**************************************************************
*
* CALCULATE FREEZE OR BOIL SUBSTANCE
* ____________________________________________________________
* This program takes user input of a temperature and outputs
* which substances will freeze or boil at the given
* temperature.
* ____________________________________________________________
* INPUT
* temperature : temperature which user inputs
*
* OUTPUT
* N/A :cout outputs which will freeze or boil
*
**************************************************************/
#include <iostream>
using namespace std;
int main() {
const int ETHYL_ALCOHOL_FREEZE = -173;
const int ETHYL_ALCOHOL_BOIL = 172;
const int MERCURY_FREEZE = -38;
const int MERCURY_BOIL = 676;
const int OXYGEN_FREEZE = -362;
const int OXYGEN_BOIL = -306;
const int WATER_FREEZE = 32;
const int WATER_BOIL = 212;
int temperature; //INPUT - temperature which user inputs
//User Input
cout << "Enter a temperature in Fahrenheit: "<<endl;
cin >> temperature;
//Output Result
cout << "At " << temperature << "°F, the following substances will freeze:" << endl;
if (temperature <= ETHYL_ALCOHOL_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;
}
cout << "At " << temperature << "°F, the following substances will boil:" << endl;
if (temperature >= ETHYL_ALCOHOL_BOIL) {
cout << "- Ethyl alcohol" << endl;
}
if (temperature >= MERCURY_BOIL) {
cout << "- Mercury" << endl;
}
if (temperature >= OXYGEN_BOIL) {
cout << "- Oxygen" << endl;
}
if (temperature >= WATER_BOIL) {
cout << "- Water" << endl;
}
return 0;
}