This project is a Temperature Converter written in COBOL. It allows users to convert temperatures between Celsius, Fahrenheit, and Kelvin. The program was designed as a command-line interface application that prompts users to select the conversion type, enter the temperature value, and displays the converted result.
The Temperature Converter offers six types of conversions:
- Celsius to Kelvin
- Celsius to Fahrenheit
- Kelvin to Celsius
- Kelvin to Fahrenheit
- Fahrenheit to Celsius
- Fahrenheit to Kelvin
After each conversion, users are asked if they would like to perform another conversion. The program ends when the user inputs 'N' in response to the prompt.
For each conversion, the program displays:
- A message describing the conversion type.
- A prompt to enter the temperature.
- The result in the converted unit.
- User sees the welcome screen.
- User selects an option (e.g., 1 for Celsius to Kelvin).
- User enters the temperature in Celsius.
- Program calculates and displays the temperature in Kelvin.
- Program prompts the user to perform another conversion or quit.
To compile and run this COBOL program, you'll need:
- GnuCOBOL (or another COBOL compiler). GnuCOBOL can be installed on Linux, Windows, and macOS. Check GnuCOBOL’s installation guide for specific instructions.
-
Compile the Program
Use the following command to compile the COBOL file:
cobc -x -o TemperatureConverter TemperatureConverter.cob
- -x: Tells GnuCOBOL to compile and link the file as an executable.
- -o TemperatureConverter: Specifies the output executable name.
-
Run the Program
Once compiled, you can execute the program with:
./TemperatureConverter
Follow the on-screen prompts to select a conversion type, input temperature values, and view the results.
If you need a Dockerfile to build a COBOL project on a different operating system, you can find it in the Docker-Hub repository on GitHub under the cobol directory. This Dockerfile provides a portable environment to compile and run COBOL code using GnuCOBOL.
This project is licensed under the MIT License. See the LICENSE file for more details.
The primary motivation behind this project was curiosity in learning COBOL. Despite being an older language, COBOL remains widely used in financial, governmental, and large-scale enterprise systems. Through building this temperature converter, I explored COBOL syntax, structured programming, and user interaction in a console environment.
Thank you for checking out this COBOL project! If you have any suggestions or feedback, feel free to reach out.