Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to convert between centigrade and fahrenheit temperatures. Your

ID: 3631213 • Letter: W

Question


Write a program to convert between centigrade and fahrenheit temperatures. Your solution must utilize functions to perform the conversions. Your functions must meet these requirements:

1. One of the functions must use pass-by-value, returning the converted measure
2. One of the functions must use pass-by-reference to store its result (the function does not have a return value).

Your program must create two tables - one showing the centigrade equivalent to fahrenheit measures from 0 degrees centigrade to 100 degrees centigrade (by 5 degree increments: 0, 5, 10, . . . , 100) and the other showing fahrenheit equivalent to centigrade measures 0 through 100 (by 5 degree increments: 0, 5, 10, ... , 100). Original measures are all integer values.

Calculated measures are to be displayed accurate to two decimal places.


The output for both tables must fit on one default screen (78 columns by 22 rows), so your tables will need to be organized into multiple columns.

Everything must be lined up nicely and the tables neatly and informatively labeled.

This assignment can be done with a single file. It is not necessary to define any classes.

I have code compiled but I'm having a hard time making two functions as required per assignment. I was able to get the table to output but I wasn't able to create both functions as required. Here's the code below:

//This program converts Celsius to Farenheit
//this program converts Farenheit in to celsius
//Will output the results in a table

//October 4 2001
//Program 7

#include <iostream>
#include <iomanip>
#include <cmath>
#include <conio.h>

using namespace std;

// function prototypes
double cent(double);
double fahr(double);

int main()
{
// headings for table output
cout << " Celsius to Fahrenheit" << setw(28)
<< "Fahrenheit to Celsius " << endl <<endl;

// four column headings for table display
cout << setw(8) << "Celsius" << setw(12) << "Fahr "
<< setw(12) << "Fahr " << setw(14) << "Celsius"<<endl << endl;

//setup for table output in increments of 5 degrees up to 100 degrees
for ( double c = 0; c <=100; c+=5 )
{
for ( double f = 0; f <= 5; f += 25 )

//table output and function call
cout << setw(6) << setprecision(0) << c + f << setw(13 )
<< setprecision(2) << fixed << fahr( c + f ) << ' '
<< setw(10) << setprecision(0) << c + f << setw(15)
<< setprecision(2) << fixed << cent( c + f ) << ' ';
cout << endl;
}
_getch();
return 0;

} // end of main function

// this function displays celsius to fahr conversion
double cent( double f )
{
return ( ( f - 32 )* 5./9. );

} // end function cent

// this function display fahr to celsius
double fahr( double c )
{
return ( 9./5. * (c + 32) );

} // end function fahr

Explanation / Answer

please rate - thanks


//This program converts Celsius to Farenheit
//this program converts Farenheit in to celsius
//Will output the results in a table

//October 4 2001
//Program 7

#include <iostream>
#include <iomanip>
#include <cmath>
#include <conio.h>

using namespace std;

// function prototypes
void cent(double&);
double fahr(double);

int main()
{double temp;
// headings for table output
cout << " Celsius to Fahrenheit" << setw(28)
<< "Fahrenheit to Celsius " << endl <<endl;

// four column headings for table display
cout << setw(8) << "Celsius" << setw(12) << "Fahr "
<< setw(12) << "Fahr " << setw(14) << "Celsius"<<endl << endl;

//setup for table output in increments of 5 degrees up to 100 degrees
for ( double t = 0; t <=100; t+=5 )
{
temp=t;
cent(temp);
cout << setw(6) << setprecision(0) << t << setw(13 )
<< setprecision(2) << fixed << fahr( t ) << ' '
<< setw(10) << setprecision(0) << t<< setw(15)
<< setprecision(2) << fixed << temp << ' ';
cout << endl;
}
_getch();
return 0;

} // end of main function

// this function displays celsius to fahr conversion
void cent( double& f )
{f=( ( f - 32 )* 5./9. );


} // end function cent

// this function display fahr to celsius
double fahr( double c )
{
return ( 9./5. * c + 32 );

} // end function fahr

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote