Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

What is necessary to implement the IMC plan?

Answered: 1 week ago