Question: #include #include #include using namespace std; int main ( ) { ifstream inputFile; ofstream outputFile; inputFile.open ( FahrenheitTemperature . txt ) ; if

#include
#include
#include
using namespace std;
int main()
{
ifstream inputFile;
ofstream outputFile;
inputFile.open("FahrenheitTemperature.txt");
if (!inputFile.is_open()){
cout << "Unable to open the input file." << endl;
return 1;
}
outputFile.open("CelciusTemperature.txt");
// Open the output file
//ofstream outputFile("CelsiusTemperature.txt");
if (!outputFile.is_open()){
cout << "Unable to open the output file." << endl;
inputFile.close();
return 1;
}
// Read the data from the input file
string city;
double temp;
while (inputFile >> city >> temp){
double celsius =(temp -32)*5.0/9.0;
outputFile << city <<""<< celsius <<"\deg C"<< endl;
}
// Close the files
inputFile.close();
outputFile.close();
cout << "Temperature conversion complete. Output file created." << endl;
return 0;
} Is the code correct because I keep getting "Unable to open the input file" even though I put it in the same directory where the solution is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!