|
Answer» 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!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
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.orgLooks awfully like homework!!!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.......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!!)
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.
|