I'm really confused by this problem and some help would be really appreciated.
Write a function named celsius get_celsius that accepts a Fahrenheit temperature as an argument and returns 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.
#include <iostream>
#include <iomanip>
using namespace std;
/****** function prototypes *********/
//Place function prototypes here.
int main()
{
double celsius;
cout << "Temperature Conversion Table\n\n";
cout << "Fahrenheit Celsius\n"
<< "____________________\n";
// Set output format
cout << fixed << showpoint << setprecision(1);
//This code creates a loop that starts the Fahrenheit variable at 0
//and continues as long as it is less than or equal to 20
for (int fahrenheit = 0; fahrenheit <= 20; fahrenheit++)
{
//declare a variable called celsius.
celsius = (5 / 9) * fahrenheit - 32;
//Make a call to the get_celsius function.
//Send in the fahrenheit variable as the argument to
//the function call.
//Place value returned by the function into the celsius variable
//Print out the celsius variable with 1 place after the decimal
//Use iomanip, setprecision, fixed, showpoint
}
return 0;
}
/*************************************************************
* get_celsius *
//Write out the get_celsius function. It takes in
//1 int parameter and returns a double value.
//The incoming parameter is a temperature value in Fahrenheit and
//the return value should be the Celsius equivalent of it.
* This function computes and returns the Celsius equivalent *
* of the Fahrenheit temperature passed to it. It does not print out the
* value in this function *
*************************************************************/
Aucun commentaire:
Enregistrer un commentaire