Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids.

#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes
void getFahrenheit();
void calcCelsius();
void displayCelsius();

int main()
{	
	//declare variables
	int fahrenheit = 0;
	double celsius = 0.0;

Here is what I have so far. I understand the middle portion of it. I'm just having a hard time understanding which variables to stick in the voids.

#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes
void getFahrenheit();
void calcCelsius();
void displayCelsius();

int main()
{	
	//declare variables
	int fahrenheit = 0;
	double celsius = 0.0;

What are you getting from fahrenheit()? Put it in there as a reference argument/parameter...

Same with calcCelsius(), except you will need 2 arguments/parameters. One will have to be a reference, the other can be a value pass or a reference, it doesn't really matter. I'll leave it to you to decide which is which.

For displayCelsius() all that you have to do is send the celsius value. You don't need a reference because you aren't trying to modify it.

#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes
	void getFahrenheit(int); 
	void calcCelsius(int, double);
	void displayCelsius(double);

int main()
{	
	//declare variables
	int fahrenheit = 0;
	double celsius = 0.0;
	
	//get input item
	getFahrenheit(fahrenheit);

	//calculate Celsius
	calcCelsius(fahrenheit, celsius);

	//display output item
	cout << fixed << setprecision(0);
	displayCelsius(celsius);

    return 0;
}   //end of main function

//*****function definitions*****

void getFahrenheit(int fahrenheit)
{
cout << "Enter Degrees in Fahrenheit: ";
cin >> fahrenheit;
} //end of getFahrenheit function

void calcCelsius (int fahrenheit, double celsius)
{
celsius = ((5.0/9.0)* (fahrenheit - 32.0));
cin >> celsius;
} //end of calcCelsius function

void displayCelsius(double celsius)
{
cout << fixed << setprecision(0);
cout << "Temperature in Celsius is: " << celsius << endl;
}

Edited 6 Years Ago by aukeebler: n/a

I tried, but it does not seem to be working. There is no error. The code is just messed up.

remove cin >> celsius; in calcCelsius.

Edit: You should use reference instead of just copying the values:

void getFahrenheit(int); // Here you copy an object from main and read a value into the copied(not the same) object.
void getFahrenheit(int&); // Here you refer to an object from main and read a value into it.

Edited 6 Years Ago by Andreas5: n/a

This question has already been answered. Start a new discussion instead.