what method to write this program?

Write a program that reads a temperature value and letter C for Celsius or F for Fahrenheit. Print whether water is liquid, solid, or gaseous at the given temperature at sea level.


should i use switch statements for this? Im just not sure how to get it to capture both the numerical and alphabetical input from user, then show either F or C values?
For reading input:
http://www.cplusplus.com/forum/articles/6046/
You can seperate the string in two part using the memberfunctions find() and substr():
http://www.cplusplus.com/reference/string/string/find.html
http://www.cplusplus.com/reference/string/string/substr.html

I would make a choose between fahrenheit or celcius, and if the user inputs the other value convert the value to the right one before checking wich state the water is.
thats what im thinking too, have an if entered F, do this, else (for C) do this

thsoe articles you posted dont help me at all, becuase im just really realy stupid when it comes to programming, i fail to see how it would be applied to my problem :(
I'll explain it in more detail :)

Get the input:
First, you'll need the input: a number and a letter. This input is stored in a single string, using getline (see first article).

Translate the input into variables:
Assuming the input is of this format: "35 C", the string need to be seperated in two parts: "35" and "C". This can be done to find the position of the space (see second article), and then use substring (see tird article) to store the two parts in two seperated strings. When this is done, you can use stringstream to convert the 'number-string' into a real number (see first article).

Find condition:
After this is done and the number is stored into a variable of type integer, we need to check in wich state the water is; solid, liquid or gaseous. I prefere celsius, because I'm used to that, so if the temprature is given in F, I need to convert it to integer. This can be done quit easily:http://en.wikipedia.org/wiki/Temperature_conversion_formulas. After we have the temprature in celcius, we can see in wich range it is (<0, 0-100,>100) and print the condition.
duuude, I have NO idea how to do this even with the articles, ill post in a second what I have attempted to write using your instructions and articles
Topic archived. No new replies allowed.