ryanshatch / Temperature-Converter

C++ program that reads temperature data in Fahrenheit from a file, converts it to Celsius, and saves the converted data in another file. It provides a simple way to convert temperature readings and parse data for multiple cities from one unit to another.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Temperature Converter

The Temperature Converter is a C++ program that reads temperature data in Fahrenheit from a file, converts it to Celsius, and saves the converted data in another file. It provides a simple way to convert temperature readings for multiple cities from one unit to another.

Features:

  • Read temperature data in Fahrenheit from a file.
  • Convert Fahrenheit temperatures to Celsius.
  • Save the converted data in a file.

Getting Started:

To use the Temperature Converter, follow these steps:

  1. Clone the repository or download the source code files.
  2. Open a terminal or command prompt and navigate to the project directory.
  3. Compile the source code using a C++ compiler:
g++ temperature_converter.cpp -o temperature_converter
  1. Run the executable:
./temperature_converter

The program will read the temperature data from the "TempInFarenheit.txt" file. Make sure this file exists in the same directory as the program.

The program will display the yearly averages of temperatures in Fahrenheit for each city.

Press Enter to convert the temperatures to Celsius.

The program will convert the temperatures and save the converted data in the "TempInCelsius.txt" file.

Check the "TempInCelsius.txt" file to view the converted temperatures.

Close the application when you're finished.

Requirements:

  • C++ IDE/Compiler

Example Output:

Yearly averages in Fahrenheit are:

New York 75
Los Angeles 85
Chicago 65
Houston 90

Press Enter to convert to Celsius.

After pressing Enter:

The temperatures in Celsius have been saved in "TempInCelsius.txt" file.

File Format:

The input file ("TempInFarenheit.txt") should contain temperature data in the following format:

City1 Temperature1
City2 Temperature2
City3 Temperature3
...

The output file ("TempInCelsius.txt") will contain the converted temperatures in Celsius, with each line following the format:

City1 Temperature1
City2 Temperature2
City3 Temperature3
...

Please note that the example output and file formats are based on the provided input values.

Conversion Formula:

The program converts Fahrenheit temperatures to Celsius using the formula:

C = (F - 32) * 5 / 9

Where C represents the temperature in Celsius, and F represents the temperature in Fahrenheit.

Error Handling:

  • If the input file ("TempInFarenheit.txt") cannot be opened, the program will display an error message and exit.
  • If the output file ("TempInCelsius.txt") cannot be opened, the program will display an error message and exit.

It is essential to ensure that the input file exists and the program has proper read and write permissions in the directory.

About

C++ program that reads temperature data in Fahrenheit from a file, converts it to Celsius, and saves the converted data in another file. It provides a simple way to convert temperature readings and parse data for multiple cities from one unit to another.


Languages

Language:C++ 100.0%