fork download
  1. //Ava Huntington CS1A Chapter 4 Homework P. 224, #20
  2. //
  3. /*******************************************************************************
  4.  * DETERMINING FREEZING/BOILING SUBSTANCES
  5.  * _____________________________________________________________________________
  6.  * This program will determine wether Ethyl Alchohol, Mercury, Oxygen, and Water
  7.  * will boil or freeze at a given temperature in Farenheit using this data:
  8.  *
  9.  * |Substance| |Freezing point (F)| |Boiling point (F)|
  10.  * Ethyl Alchohol -173 172
  11.  * Mercury -38 676
  12.  * Oxygen -362 -306
  13.  * Water 32 212
  14.  * _____________________________________________________________________________
  15.  * INPUT
  16.  * givenTemp: Temperature given
  17.  *
  18.  * OUTPUT
  19.  * frozenSubstance: Specified substance will freeze at given temperature
  20.  * boilingSubstance: Specified substance will boil at given temperature
  21.  ******************************************************************************/
  22. #include <iostream>
  23. using namespace std;
  24.  
  25. int main()
  26. {
  27. float givenTemp; //INPUT: Temperature given
  28.  
  29. //Prompt to get temperature input
  30. cout << "Please enter a temperature in farenheit and I will tell you wether"
  31. " the substances Ethyl Alchohol, Mercury, Oxygen, and Water will freeze or"
  32. " boil at the given temperature"<<endl;
  33. cin >> givenTemp;
  34.  
  35. //Display given temperature
  36. cout << "You entered " << givenTemp << " degrees farenheit." << endl;
  37.  
  38. //CHECK FOR FREEZING
  39.  
  40. if (givenTemp<=-173)
  41. cout << "Ethyl Alchohol will freeze at this temperature."<< endl;
  42.  
  43. if (givenTemp<=-38)
  44. cout << "Mercury will freeze at this temperature." << endl;
  45.  
  46. if (givenTemp<=-362)
  47. cout << "Oxygen will freeze at this temperature." << endl;
  48.  
  49. if (givenTemp<=32)
  50. cout << "Water will freeze at this temperature." << endl;
  51.  
  52. else if (givenTemp>32)
  53. cout << "None of the substances will freeze at this temperature."<< endl;
  54.  
  55. //CHECK FOR BOILING
  56.  
  57. if (givenTemp>=172)
  58. cout << "Ethyl Alchohol will boil at this temperature." << endl;
  59.  
  60. if (givenTemp>=676)
  61. cout << "Mercury will boil at this temperature." << endl;
  62.  
  63. if (givenTemp>=-306)
  64. cout << "Oxygen will boil at this temperature." << endl;
  65.  
  66. if (givenTemp>=212)
  67. cout << "Water will boil at this temperature." << endl;
  68.  
  69. else if (givenTemp<-306)
  70. cout << "None of the substances will boil at this temperature." << endl;
  71. return 0;
  72. }
  73.  
Success #stdin #stdout 0.01s 5284KB
stdin
12

stdout
Please enter a temperature in farenheit and I will tell you wether the substances Ethyl Alchohol, Mercury, Oxygen, and Water will freeze or boil at the given temperature
You entered 12 degrees farenheit.
Water will freeze at this temperature.
Oxygen will boil at this temperature.