/***************************************************
H 0 State Program
2
Write a program that reads in a temperature in the
form of NUMBER UNITS (e.g "123.02 Fahrenheit" or
"-75.0 Celsius") and returns "Gas", "Liquid", or
"Solid" depending on the state of H20 at that
temperature. Note: We'll assume standard pressure.
At standard pressure, we have ice at or below
32 Fahrenheit (0 Celsius), steam above 212
Fahrenheit (100 Celsius), and water in between.
***************************************************/
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Read user input temperature
double T;
string units;
cout << "Enter temperature (NUMBER UNITS): ";
cin >> T >> units;
// Respond appropriately to English or Metric
if (units == "Fahrenheit")
{
// THIS BLOCK IS FOR ENGLISH UNITS
if (T >= 212)
{
cout << "Gas" << endl;
}
else
{
if (T <= 32)
{
cout << "Solid" << endl;
}
else
{
cout << "Liquid" << endl;
}
}
}
else
{
// THIS BLOCK IS FOR METRIC UNITS
if (T >= 100)
{
cout << "Gas" << endl;
}
else
{
if (T <= 0)
{
cout << "Solid" << endl;
}
else
{
cout << "Liquid" << endl;
}
}
}
return 0;
}