fork download
  1. // Elaine Torrez Chapter 4 P. 224, #20
  2. /**************************************************************************
  3.  * FREEZING AND BOILING POINTS
  4.  * ------------------------------------------------------------------------
  5.  * This program asks the user to enter a temperature in Fahrenheit.
  6.  * It then displays which substances will freeze and which will boil
  7.  * at that temperature. The substances checked are:
  8.  * Ethyl alcohol, Mercury, Oxygen, and Water.
  9.  * ------------------------------------------------------------------------
  10.  * INPUT
  11.  * temperature : The temperature entered by the user (°F)
  12.  *
  13.  * OUTPUT
  14.  * Statements indicating whether each substance will freeze or boil
  15.  * at the entered temperature.
  16.  **************************************************************************/
  17.  
  18. #include <iostream>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. double temperature; // User input temperature in Fahrenheit
  24.  
  25. // Prompt user for input
  26. cout << "Enter a temperature in Fahrenheit: ";
  27. cin >> temperature;
  28.  
  29. // Check Ethyl alcohol
  30. if (temperature <= -173)
  31. cout << "Ethyl alcohol will freeze.\n";
  32. if (temperature >= 172)
  33. cout << "Ethyl alcohol will boil.\n";
  34.  
  35. // Check Mercury
  36. if (temperature <= -38)
  37. cout << "Mercury will freeze.\n";
  38. if (temperature >= 676)
  39. cout << "Mercury will boil.\n";
  40.  
  41. // Check Oxygen
  42. if (temperature <= -362)
  43. cout << "Oxygen will freeze.\n";
  44. if (temperature >= -306)
  45. cout << "Oxygen will boil.\n";
  46.  
  47. // Check Water
  48. if (temperature <= 32)
  49. cout << "Water will freeze.\n";
  50. if (temperature >= 212)
  51. cout << "Water will boil.\n";
  52.  
  53. return 0;
  54. }
  55.  
  56.  
Success #stdin #stdout 0.01s 5284KB
stdin
21
stdout
Enter a temperature in Fahrenheit: Oxygen will boil.
Water will freeze.