Question
Question 1 To convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius temperature and F = Fahrenheit temperature: C =
Question 1
To convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius temperature and F = Fahrenheit temperature:
C = 5/9 * (F-32)
Write a C++ temperature conversion program which does the following:
- Write a function called toCelsuis which takes a Fahrenheit temperature as a parameter, and returns the equivalent Celsius temperature:
float toCelsius(float)
-
Demonstrate that your function works by writing a main() function that prints out a conversion table. It should have Fahrenheit values 60, 61, 62, ... through 80 (21 temperatures in total) and should also have the corresponding Celsius temperatures that your function calculated. So your output should look something like this:
Welcome to the temperature table! F C 60 15.6 61 16.1 ... ... 80 26.7
-
If you like: you can add this line in your function to make floating point output fixed, make sure you #include
cout.setf(ios::fixed, ios::floatfield);
- If you like: you can then call setprecision(1) in your cout statements to print out one decimal place, e.g.
cout << setprecision(1) << celsius;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started