This is what I have already but I dont know if I am meeting the specs for my assingment... anyone have any input of what I should do?

Assignment is Write a program that will ask the user for a temperature in Centigrade (Celsius) and convert it to the Fahrenheit scale. Then it will classify the temperature as either "steam", "water" or "ice". You will have to research the temperatures where water changes from one state to another. You will have to find the equation that converts from one scale to the other. State your references in a comment in your program file.
Write the temperature scale (C to F) conversion as a float function with one parameter. The function should not do any input from the keyboard nor output to the screen.
The classification should be done in another function which will return a string value. It should have one parameter. It should be written with as few comparisons as possible.
The main function will act as a driver, getting the input from the user and then calling the functions and reporting the results of the function calls.

my Program that Ihave so far is

#include <iostream>
#include <string>
using namespace std;

void cel_to_far (int celsius, int fahrenheit);
string state_of_water (int fahrenheit);

int celsius;
int fahrenheit;

int main ()

cout << "Enter the degrees of water in in celsius.       ";
cin >> celsius;
cout << endl;
cout << "When you have " << celsius << " degrees, that is equal to " << cel_to_far << " degrees, Fahrenheit" << endl;
cout << endl;
cout << state_of_water << endl;

return 0;
void cel_to_far (int celsius, int fahrenheit)
fahrenheit = celsius * 9 / 5 + 32;

string state_of_water (int fahrenheit)
	if (fahrenheit <= 32)
		return "Solid (ice)";
	if (fahrenheit >= 33 && fahrenheit <= 211)
		return "Liquid (water)";
		return "Gas (steam)";

Function calls always require paranthesies(), even if there are no parameters.
In your case you'd have to do something like:

int celcius, farenheit;
cel_to_far(celcius, farenheit);
cout << "When you have " << celsius << " degrees, that is equal to " << farenheit << " degrees, Fahrenheit" << endl;
cout << "Water becomes " << state_of_water(farenheit) << " at this temperature." << endl;

Your cel_to_far function won't work, though. Either you should change it to void cel_to_far(int celcius, int& farenheit) or int cel_to_far(int celcius).
The first option would place the temperature in farenheit in the variable named farenheit. The second one would return the temperature in farenheit, just like your other function returns a string.
Both ways works, it's just a matter of what you prefer

Edited 7 Years Ago by BeyondTheEye: n/a

This article has been dead for over six months. Start a new discussion instead.