Temperature Conversion Program - Still a Rookie

D

Default User

Ian said:
James Kanze wrote:

Please fix this - it's a pain to have to keep manually trimming your
signature.

Heh, I was going to mention that as well. James, your .sig separator is
missing a character. It should be "-- " (dash dash space).




Brian
 
A

AsheeG87

Thank you guys!
Your criticism and suggestions helped me! I appreciate you guys taking
the time to critique me! I got it to work finally!

And I found this funny....
"He made no mention of a complier, just that the code wouldn't
compile
without it. On my system, it won't compile with it!

--
Ian Collins. "

Hahaha...I'm a girl. So..."She made no mention....". ;) Just thought
I'd let ya know Ian!

But, again, I appreciate all of your help!

~Ashley~

So, here is the final code:
// Temperature.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;

float FahrenheittoCelsius(float f); //Function Prototype
float CelsiustoFahrenheit(float c);
float result = 0;


int main()
{
float tempFahrenheit = 0;
float tempCelsius = 0;
float temp = 0;
char corf = 'f';
char yorn = 'y';



cout << " Enter the Temperature: "; //Prompt user to enter temp
cin >> temp;
cout << " Fahrenheit or Celsius? ";
cin >> corf;


if (corf == 'f')
{
FahrenheittoCelsius(temp);
cout << temp << " degrees Fahrenheit is" << result << " degrees
celsius " << endl;
}
else if (corf == 'c')
{
CelsiustoFahrenheit(temp);
cout << temp << " degrees Celsius is " << result << " degrees
Fahrenheit" << endl;
}

cout << " Continue? Y or N ";
cin >> yorn;
while (yorn == 'y')
{
cout << " Enter the Temperature: "; //Prompt user to enter temp
cin >> temp;
cout << " Fahrenheit or Celsius? ";
cin >> corf;

if (corf == 'f')
{
FahrenheittoCelsius(temp);
cout << temp << " degrees Fahrenheit is" << result << " degrees
celsius " << endl;
}
else if (corf == 'c')
{
CelsiustoFahrenheit(temp);
cout << temp << " degrees Celsius is " << result << " degrees
Fahrenheit" << endl;
}
cout << " Continue? Y or N ";
cin >> yorn;
}

while (yorn != 'n')



return 0;
}
float FahrenheittoCelsius (float f)
{
result = 5.0 / 9.0 * (f - 32);
return result;
}
float CelsiustoFahrenheit (float c)
{
result = (9.0 / 5.0 * c) + 32;
return result;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top