English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

If you wish, create two functions that convert fahrenheit to celsius and celsius to fahrenheit and use them to convert a temperature of each scale. Otherwise, just write code to perform the conversions.


Whoever answers this please send me an email at patrickjohnathan@yahoo.com with your email address so that we may keep in touch. Im currently taking to CS courses that are currently kicking my behind please if you would lend me your knowledge.Thanks

2007-02-25 12:15:41 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

Hi there,

Well the query you asked, for this first you have to understand the formulas used to convert celsius to fahrenheit and vice versa. Once the formula is clear to you, you can implement the same in any of the programming languages. I have taken C++ to show you the code.

I am sharing very important information regarding the temperature. I hope this information will help you a lot: -

" What's the difference between the Fahrenheit and Celsius temperature scales?
Before we discuss the difference between the two temperature scales, let's focus on the similarities. Both scales are based on the freezing conditions of water, a very common and available liquid. Since water freezes and boils at temperatures that are rather easy to generate (even before modern refrigeration), it is the most likely substance on which to base a temperature scale.
On the Fahrenheit scale, the freezing point of water is 32 degrees and the boiling point is 212 degrees. Zero Fahrenheit was the coldest temperature that the German-born scientist Gabriel Daniel Fahrenheit could create with a mixture of ice and ordinary salt. He invented the mercury thermometer and introduced it and his scale in 1714 in Holland, where he lived most of his life.

Anders Celsius, a Swedish astronomer, introduced his scale is 1742. For it, he used the freezing point of water as zero and the boiling point as 100. For a long time, the Celsius scale was called "centigrade." The Greek prefix "centi" means one-hundredth and each degree Celsius is one-hundredth of the way between the temperatures of freezing and boiling for water. The Celsius temperature scale is part of the "metric system" of measurement (SI) and is used throughout the world, though not yet embraced by the American public.

Scientists use a third scale, called the "absolute" or Kelvin scale. This scale was invented by William Thomson, Lord Kelvin, a British scientist who made important discoveries about heat in the 1800's. Scientists have determined that the coldest it can get (theoretically) is minus 273.15 degrees Celsius. This temperature has never actually been reached, though scientists have come close. The value, minus 273.15 degrees Celsius, is called "absolute zero". At this temperature scientists believe that molecular motion would stop. You can't get any colder than that. The Kelvin scale uses this number as zero. To get other temperatures in the Kelvin scale, you add 273 degrees to the Celsius temperature.

Maybe you could record your weather data in all three temperature scales for a few days. Imagine that it's going to be 59 degrees Fahrenheit. That's the same as 15 degrees Celsius. Add 273 to 15 and you get a Kelvin temperature of 288 degrees.

Scientists use the Kelvin scale because some of the math they do to figure out weather doesn't work if they use minus numbers for temperatures. This explains why in scientific temperatures you'll see references to temperatures on Earth in the 300-degree range.


To convert Fahrenheit temperatures into Celsius:
Begin by subtracting 32 from the Fahrenheit number.
Divide the answer by 9.
Then multiply that answer by 5.
Here's an example: Change 95 degrees Fahrenheit to Celsius: 95 minus 32 is 63. Then, 63 divided by 9 is 7. Finally, 7 times 5 is 35 degrees Celsius. Time to go to the beach!


To convert Celsius temperatures into Fahrenheit:
Begin by multiplying the Celsius temperature by 9.
Divide the answer by 5.
Now add 32.
Here's an example: Change 20 degrees Celsius to Fahrenheit: 20 times 9 is 180. Then 180 divided by 5 is 36. Finally, 36 plus 32 is 68 degrees Fahrenheit. That would be a pretty comfortable outside temperature for taking a walk!!


Using an Algebraic Formula:
For the mathematically daring, here is the algebraic formula used for conversion from Fahrenheit to Celsius:

Tc=(5/9)*(Tf-32)
Tc=temperature in degrees Celsius Tf=temperature in degrees Fahrenheit
* means multiply


Now, to convert from Celsius to Fahrenheit,:

Tf=(9/5)*Tc+32
Tc=temperature in degrees Celsius Tf=temperature in degrees Fahrenheit. "


Now the same is implemented in the following code: -


#include
#include

int cels_fahren(int tc)
{
int tf;
tf=tc+32*(9/5);
return(tf);
}

int fahren_cels(int tf)
{
int tc;
tc=tf-32*(5/9);
return(tc);
}

void main()

{
clrscr();
int tc, tf, ch;

cout<<"1.Celsius to Fahrenheit Conversion"< cout<<"2.Fahrenheit to Celsius Conversion"< cout<<"Please enter your choice either 1 or 2"< cin>>ch;

switch (ch)
{
case 1:
{
cout<<"Please enter temperature in celsius"< cin>>tc;
tf=cels_fahren(tc);
cout<<"Temperature in Fahrenheit Degrees\t"< break;
}

case 2:
{
cout<<"Please enter temperature in Fahrenheit"< cin>>tf;
tc=fahren_cels(tf);
cout<<"Temperature in Celsius Degrees\t"< break;
}
}
}


Further if you need any kind of help, contact me at coolcanc@yahoo.com.

2007-02-25 12:35:26 · answer #1 · answered by Santosh 2 · 0 0

Well, it would help if you said what language you were trying to do this in.

Generally, though, this is the conversion:

To convert Fahrenheit temperatures into Celsius:

* Begin by subtracting 32 from the Fahrenheit number.
* Divide the answer by 9.
* Then multiply that answer by 5.

To convert Celsius temperatures into Fahrenheit:

* Begin by multiplying the Celsius temperature by 9.
* Divide the answer by 5.
* Now add 32.

So, set up two functions, such as f2c and c2f (just to be simple), pass in the temp, do the math, return the value.

As an example (in C)

int c2f(int celsius)
{
int f;

f = c * 9;
f = f / 5.0;
f = f + 32;

return(f);
}


And the equivalent for the other direction. As for email addresses, sorry, I believe you should try to noodle out as much as you can. Good luck!

2007-02-25 20:23:13 · answer #2 · answered by T J 6 · 0 0

fedest.com, questions and answers