Start by writing a program that converts Celsius temperatures to Fahrenheit temperatures. The formula is F = (9/5)C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature. Enhance the program by allowing the user to choose between converting from Celsius to Fahrenheit and vice versa. See the below output. You will need to look up the formula for the other directions (simply google it!). Allow for both upper and lower-case menu item selections and generate an appropriate error message if the user enters something unexpected. Format your output to always show one decimal. You will build on this assignment in future chapters.
The output should look something like this:
Enter c (or C) to convert Fahrenheit to Celsius
or f (or F) to convert Celsius to Fahrenheit: c
Enter the temperature: 0.0
0.0 Celsius is 32.0 degrees Fahrenheit.
Running the program again:
Enter c (or C) to convert Fahrenheit to Celsius
or f (or F) to convert Celsius to Fahrenheit: F
Enter the temperature: 212
212.0 Fahrenheit is 100.0 degrees Celsius.
Any and all help would be appreciated as this is all I could come up with because finals are coming p and I need to get this and many other assignments done asap
Please use code tags. Edit your post, highlight the code and press the <> button to the right of the edit window. This will make your code appear with line numbers so we can refer to it.
Line 19: add else and combine with line 20
Line 25: Change 5 / 9 to 5.0 / 9.0. 5/9 invokes integer division and creates an integer result of 1.
Change lines 30 & 31 to
1 2 3
else {
cout << "Invalid input\n";
}
That will get the code to compile. Run some simple tests and you'll find that you still have some problems but I think you'll be able to figure them out.