I need the solution to question number 7 on page 374. \"Starting out with >>> C+
ID: 3869913 • Letter: I
Question
I need the solution to question number 7 on page 374.
"Starting out with >>> C++ From Control Structures through Objects" Ninth Edition
Author: Tony Gaddis
ISBN: 9780134498379
Question:
The formula for converting a temperature from Fahrenheit to Celsius is
C= 5/9(F-32)
where F is the Fahrenheit temperature and C is the celsius temperature. Write a function named "celsius" that accepts a Fahrenheit temperature as an argument. The function should return the temperature, converted to Celsius. Demonstrate the function by calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their celsius equivalents.
Other directions:
How many conversions are we going to do? 21 conversions
How many conversions are we coding? Unlimited
What alignment is our data going to be? Right
Put boxes around all our numbers
All numbers must be WHOLE numbers
Write a function named CELSIUS
Accept a Fahrenheit value/reference being passed in in an argument
The function should return a temperature value in Celsius
Demonstrate the function by calling it in a loop
Fahrenheit temperatures have to be 0 thru 20 and their Celsius equivalents
Example table: Vertical Table 2 columns boxes around numbers
Menu should be centered on the screen
Data types are double
Decimal places should be set precision to 2 places
Explanation / Answer
Please find code below.
#include <iostream>
#include <iomanip>
float celsius(int Fahrenheit){
return (5.0/9*(Fahrenheit - 32));
}
int main()
{
int i;
std::cout<<std::setprecision(2)<<std::fixed;
std::cout<<"Fahrenheit Celsius ";
for(i=0;i<=20;i++)
std::cout<<i<<" "<<celsius(i)<<" ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.