# [SOLVED] I need help with a c++ program



## dmb168 (Sep 17, 2007)

Add to my Fahrenheit to Celsius program: 

Develop some kind of a loop - allowing the user to run more than one temperature and then quit when they want to quit. 

Two conditionals - if the converted C temp is greater than 37 degrees Celsius than display the text "its freaking hot outside" (or) if the converted C temp is less than -17 degrees Celsius display the text "Its freaking cold outside!!!"

Wondering if I could get some help with this.

Max


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

please upload your unfinished c++ program. so we take it from there...


----------



## dmb168 (Sep 17, 2007)

*Re: I need help with a c++ program*

#include <iostream>
using namespace std;

int main()
{
string name;
cout << "Enter name " << endl;
cin >> ws;
getline (cin, name);
cout << "Hi " << name.c_str() << endl;

double fahrenheit, celsius;

cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(1);

cout << "Please enter the temperature in Fahrenheit: ";
cin >> fahrenheit;

celsius = 5.0 / 9.0 * (fahrenheit - 32.0);
cout << fahrenheit
<< " degrees Fahrenheit is the same as "
<< celsius
<< " degrees Celsius" << endl;

fahrenheit = fahrenheit = temp * 9/5 + 32;
<< "degrees in celsius is the same as "
<< fahrenheit 
<< " degrees fahrenheit" << endl;

cout << "Thank you " << name.c_str() << endl;

return 0;
}


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

is this coding able to run properly in your compiler so far?


----------



## dmb168 (Sep 17, 2007)

*Re: I need help with a c++ program*

No I'm having trouble with the fahrenheit equals part. I don't even know where to start with the loop and so on.

#include <iostream>
using namespace std;

int main()
{
string name;
cout << "Enter name " << endl;
cin >> ws;
getline (cin, name);
cout << "Hi " << name.c_str() << endl;

double fahrenheit, celsius;

cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(1);

cout << "Please enter the temperature in Fahrenheit: ";
cin >> fahrenheit;

celsius = 5.0 / 9.0 * (fahrenheit - 32.0);
cout << fahrenheit
<< " degrees Fahrenheit is the same as "
<< celsius
<< " degrees Celsius" << endl;

fahrenheit = temp * (9/5) + 32;
<< "degrees in celsius is the same as "
<< fahrenheit 
<< " degrees fahrenheit" << endl;

cout << "Thank you " << name.c_str() << endl;

return 0;
}


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

ok please give me a few minutes to sort this out


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

your program requirement is to convert F temp to C only and display appropriate TEXT if necessary. Then why are you trying to use F formula??? are you trying to convert the temp back to farenheit?? if so, u don't need to, u already have it.


----------



## dmb168 (Sep 17, 2007)

*Re: I need help with a c++ program*

What I'm trying to do is to develop some kind of a loop allowing the user to run more than one temperature and then quit when they want to quit.


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

try the following coding and tell me if it fulfills the program requirements.


#include <iostream>
using namespace std;

int main()
{
// float temp;
string name;
cout << "Enter Name : ";
cin >> ws;
getline (cin, name);
cout << endl << "Hello " << name.c_str() << endl;

double fahrenheit, celsius;

cout.setf(ios::fixed, ios::floatfield);
cout.setf(ios::showpoint);
cout.precision(1);

cout << "Please enter the temperature in Fahrenheit (enter 999 to end): ";
cin >> fahrenheit;

while (fahrenheit != 999)
{
celsius = 5.0 / 9.0 * (fahrenheit - 32.0);

cout << endl << fahrenheit
<< " degrees Fahrenheit = "
<< celsius
<< " degrees Celsius" << endl;

if (celsius > 37)
cout << "its freaking hot outside" << endl;
else if (celsius < 17)
cout << "Its freaking cold outside!!!" << endl;
else;

cout << endl << "Please enter the temperature in Fahrenheit (enter 999 to end): ";
cin >> fahrenheit;
}//end while

cout << endl << "Thank you " << name.c_str() << endl << "Good bye...." << endl;

system("PAUSE");
return 0;
}


----------



## dmb168 (Sep 17, 2007)

*Re: I need help with a c++ program*

Hey thank you very much.

Max


----------



## techsoul (Jun 7, 2007)

*Re: I need help with a c++ program*

no problem. study everything in your program and ASK questions. otherwise u wouldn't learn anything from this. i will be glad to answer any questions u have regarding this. i m sure u will find all the help in your C++ book as well.

all the best


----------

