Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: C++ program for this formula  (Read 7025 times)

0 Members and 1 Guest are viewing this topic.

KD

  • Guest
C++ program for this formula
« on: March 08, 2005, 09:18:15 PM »
How do I write a program to convert centigrade temperatures to Fahrenheit temperatures, using this formula:   F=9 0ver 5 C + 32?  pow....maybe?  pow is still confusing me.  HELP!

gussery

  • Guest
Re: C++ program for this formula
« Reply #1 on: March 09, 2005, 05:21:26 AM »
It's just math.  It doesn't matter much what the programming language is, it is just math.
1. Create some interface to gather the centigrade temperature from the end user.
2. Do the math.
3. Provide some feedback to the user with the result.

Below is a Visual Basic Script that will do what you ask in 5 lines.  It is not much different in Java Script, Visual Basic, C++, C#, VBA, etc., etc., etc.

dim c
dim f
c = InputBox("Please enter centigrade temperature")
f = (9 / 5) * c + 32
msgbox f


Corrosive

  • Guest
Re: C++ program for this formula
« Reply #2 on: March 09, 2005, 02:02:30 PM »
C++ is a very difficult language to get your head round for the first time. I'd advise you either learn C (which is similar, but if you've programmed before it should make sense) or better yet use my favourite language, Python - www.python.org

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: C++ program for this formula
« Reply #3 on: March 09, 2005, 08:13:21 PM »
Looks awfully like homework!!!
One good deed is worth more than a year of good intentions.

kd

  • Guest
Re: C++ program for this formula
« Reply #4 on: March 15, 2005, 11:10:20 AM »
Thanks gussery!  Needless to say, I also forgot the floating-point.  Had to use 9.0.
Yes....Dusty......it's homework.  Encarta directed me to this site for help.  As a C++ student, with lousy math skills, I'm trying to educate myself on these mathematical assignments.  Sorry to have bothered you with my needs. ;)
Thanks for the suggestion corrosive; however, the college only teaches C++ at this time.  Bummer.......

Dusty



    Egghead

  • I could if she would, but she won't so I don't.
  • Thanked: 75
  • Experience: Beginner
  • OS: Windows XP
Re: C++ program for this formula
« Reply #5 on: March 15, 2005, 06:15:31 PM »
Okay - mebbe my comment was kinda unnecessary.. but the usual way to get help on programming is to submit what you've written and ask for assistance

If you want to do some work at home on C/C++ you need:

a.  Access to a tutorial.  Here's one and ok its C but it will help

http://computer.howstuffworks.com/c.htm


b. Access to a compiler to allow you to test-run what you've written - see here http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/index.html#Top


c. Access to a specialised forum where help is always willingly given - but note you will have to provide what code has already been written by you...  The link below has tutorials & forum available

http://www.programmersheaven.com/zone3/index.htm

Good luck - C/C++ is fun (believe it or not!!)

One good deed is worth more than a year of good intentions.

johnwill

  • Guest
Re: C++ program for this formula
« Reply #6 on: March 19, 2005, 03:27:35 PM »
Since you want floating point, you'd probably want:

f = (9.0 / 5.0) * c + 32

A plain 9 or 5 is interpreted as an integer, and the result of that division would be 1, so I suspect the results would not be as intended. :)