| terryowen100 (10) | |
|
I am new in c++, i need someone to help me write the code for this program: Write a program that prompts the user to enter the weight of a person in kilograms and outputs the equivalent in pounds. Output both the weights rounded to two decimal places. (Note that 1 kilogram = 2.2 pounts.) Format your output with two decimal places. With this question I don't know how to code it to where i would input it in kilograms and output it in pounds. Thank you | |
|
|
|
| ResidentBiscuit (2651) | |
|
Think about the requirements. First off... You need a way to perform basic I/O. (iostream) Second, you need to prompt the user to input kilograms, and store that value. Third, you need to perform a calculation that will convert to pounds. A google search will get you the formula for that. Fourth, you need to output this new value. Have you programmed at all yet? | |
|
|
|
| terryowen100 (10) | |
|
I am new to c++ just wrote my first program using the below: #include <iostream> using name space std; int main () { cout << "c++ programming is fun!\n"; system ("PAUSE"); } my teacher gave the above as a research assignment, please can you help me? I can copy it and run... just help me write the correct program code | |
|
|
|
| chrisname (6192) | |||
Here is the correct code:
Make sure your lecturer compiles it with "-std=c++11" (tell him that, he'll understand what I mean). | |||
|
|
|||
| ResidentBiscuit (2651) | |
| Oooh chrisname, that just made my day :D | |
|
|
|
| chrisname (6192) | |
|
Thanks :) It'd be prettier if I had formatted the data into columns, but I was too lazy. I think the rest of it is nice code, though. | |
|
|
|
| ResidentBiscuit (2651) | |
| For some reason I have a feeling OP would not even notice the difference if you had. | |
|
|
|
| chrisname (6192) | |
| Probably not. | |
|
|
|
| terryowen100 (10) | |
|
Thanks Chrisname for the code, But i tried to complie it with dev-c++ 4.9.9.2. But it returns error, did you run this code after writing it? Please help me because I am to complie it myself and submit finished work. | |
|
|
|
| atropos (177) | |
|
I have to say, that is a very elegant solution to this kind of problem. | |
|
|
|
| terryowen100 (10) | |
| it needs debugging | |
|
|
|
| ResidentBiscuit (2651) | |
| Well, you can debug it. Can't you? I mean, you wrote this as far as the professor is concerned. | |
|
|
|
| CodeMonkey (661) | |||
You would better spend your time reading than trying to get handouts here. | |||
|
|
|||
| Catfish2 (666) | |||
Following thorough investigation, I found that Chrisname's program also works correctly with much less data.
| |||
|
|
|||
| shadow123 (125) | |||
YMMD :D | |||
|
Last edited on
|
|||
| chrisname (6192) | |||
| |||
|
|
|||