![]() |
VOOZH | about |
In this project, you will build a simple command-line application that allows users to convert temperatures between Celsius and Fahrenheit. The program should take the user’s choice, perform the appropriate conversion, and display the result. It should continue running based on the user's input and handle invalid choices appropriately, as described in the features below.
Our temperature converter program will have the following features:
Example:
Try to solve this yourself before looking at the solution below.
You must be familiar with the following topics in C++:
We start by defining constexpr constants for the conversion factors.
Then, we use a while (true) loop to keep the converter running. Inside the loop, we display a menu and take user input. Based on the input, the appropriate conversion is performed. Input is validated to handle invalid menu choices.
When you compile and run the program, it displays:
In this project, we learned:
You can also extend this program to support kelvin (K) also.