fork download
  1. //Jacklyn Isordia CSC5 Chapter 4, P. 224, #20
  2. //
  3. /**************************************************************
  4.  *
  5.  * Finding the freezing and boiling points
  6.  * ____________________________________________________________
  7.  *
  8.  * This program asks the user to enter a temperature and then
  9.  * displays all substances that will freeze or boil at that
  10.  * temperature.
  11.  * ____________________________________________________________
  12.  * INPUT
  13.  * temperature : Fahrenheit
  14.  *
  15.  * OUTPUT
  16.  * temperature : substances that freeze or boil
  17.  *
  18.  **************************************************************/
  19.  
  20. #include <iostream>
  21. using namespace std;
  22.  
  23. int main() {
  24. const int ETHYL_ALCOHOL_FREEZE = -173;
  25. const int ETHYL_ALCOHOL_BOIL = 172;
  26. const int MERCURY_FREEZE = -38;
  27. const int MERCURY_BOIL = 676;
  28. const int OXYGEN_FREEZE = -362;
  29. const int OXYGEN_BOIL = -306;
  30. const int WATER_FREEZE = 32;
  31. const int WATER_BOIL = 212;
  32. int temperature;
  33.  
  34. cout << "Enter a temperature in Fahrenheit: ";
  35. cin >> temperature;
  36.  
  37. if (temperature <= ETHYL_ALCOHOL_FREEZE)
  38. cout << "Ethyl alcohol will freeze." << endl;
  39. if (temperature >= ETHYL_ALCOHOL_BOIL)
  40. cout << "Ethyl alcohol will boil" << endl;
  41. if (temperature <= MERCURY_FREEZE)
  42. cout << "Mercury will freeze." << endl;
  43. if (temperature >= MERCURY_BOIL)
  44. cout << "Mercury will boil" << endl;
  45. if (temperature <= OXYGEN_FREEZE)
  46. cout << "Oxygen will freeze." << endl;
  47. if (temperature >= OXYGEN_BOIL)
  48. cout << "Oxygen will boil" << endl;
  49. if (temperature <= WATER_FREEZE)
  50. cout << "Water will freeze." << endl;
  51. if (temperature >= WATER_BOIL)
  52. cout << "Water will boil" << endl;
  53.  
  54. return 0;
  55. }
Success #stdin #stdout 0s 5312KB
stdin
-200
stdout
Enter a temperature in Fahrenheit: Ethyl alcohol will freeze.
Mercury will freeze.
Oxygen will boil
Water will freeze.