I want to read this file to read each temperature and have it tell me if one of the substances listed will freeze or boil. My code is only reading the last temperature. And I am also having trouble understanding what the question wants me program exactly. I have the question to this program commented out within the code and not sure if I'm doing mrs than asked. Im self-learning and aging trouble. If some one can help explain and solve my issue, it'll be very much appreciated.
-------------------------------------------------------------------------------
/*
Modify the freezing and boiling points program described in Programming Challenge 20 so it reads its input from a file instead of from the keyboard. Perform the necessary test to deter- mine if an error occurs when the file is opened. If an error occurs, display a message informing the user. The following data to test your program can be found in the FrzBoil.dat file.
-173 -38 -362 32
172 676 -306 212
*/
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream outputFile;
ifstream inFile;
if (temperature <= -362)
{
cout << "Ethyl Alcohol, Mercury, Oxygen and Water all freeze at " << temperature << " degrees." << endl;
exit(0);
}
else if (temperature <= -173 && temperature > -362)
{
cout << "Ethyl Alcohol, Mercury and Water all freeze at " << temperature << " degrees." << endl;
cout << "Oxygen will boil at " << temperature << " degrees." << endl;
exit(0);
}
else if (temperature <= -38 && temperature > -173)
{
cout << "Mercury and Water will freeze at " << temperature << " degrees." << endl;
cout << "Oxygen will boil at " << temperature << " degrees." << endl;
exit(0);
}
else if (temperature <=32 && temperature > -38)
{
cout << "Water will freeze at " << temperature << " degrees." << endl;
exit(0);
}
if (temperature >= 172 && temperature < 212)
{
cout << "Ethyl Alcohol and Oxygen boil at " << temperature << " degrees." << endl;
exit(0);
}
else if (temperature >= 212 && temperature < 676)
{
cout << "Ethyl Alcohol, Oxygen and Water boil at " << temperature << " degrees." << endl;
exit(0);
}
else if (temperature >= 676)
{
cout << "Ethyl Alcool, Oxygen, Water, and Mercury boil at " << temperature << " degrees." << endl;
exit(0);
}
}