By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,849 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

program that read weight in pounds & ounces & will output the equivalent in kg and g?

P: 1
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void input(int& pounds, int& ounces, int& kg, int& g);
  6. void calculating(int& pounds, int& ounces, int& kg, int& g);
  7. void output(int& pounds, int& ounces, int& kg, int& g);
  8.  
  9. int main()
  10.  
  11. {
  12.     int pounds;
  13.     int ounces;
  14.     int kg;
  15.     int g;
  16.     char repeat;
  17.  
  18.     do
  19.     {
  20.     input(pounds, ounces, kg, g);
  21.     calculating(pounds, ounces, kg, g);
  22.     output(pounds, ounces, kg, g);
  23.  
  24.     cout<<"Do you want to continue? (Y/N): " << endl;
  25.     cin >> repeat;
  26.     }
  27.  
  28.     while(repeat == 'y' || repeat == 'Y');
  29.     return 0;
  30. }
  31.  
  32. void input(int& pounds, int& ounces, int& kg, int& g);
  33. {
  34.     do
  35.     {
  36.     cout << "Please enter pounds: ";
  37.     cin >> pounds;
  38.     if(pounds = 2.2046) 
what next?? can you help me??
Sep 13 '10 #1
Share this Question
Share on Google+
3 Replies


code green
Expert 100+
P: 1,726
You need to write three functions
Expand|Select|Wrap|Line Numbers
  1. input(); 
  2. calculating(); 
  3. output()
At least that is what your tutor is suggesting.
But I used to ignore these startup helps with my assignments and start afresh.
Sep 13 '10 #2

100+
P: 542
.....and a 4th one
Expand|Select|Wrap|Line Numbers
  1. yes_no();/*might be worth while also*/
Sep 14 '10 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
I would spend some time with Units of Measure.

That is, I would keep my data in a common unit, like grams. Then I would write functions that:

grams->ounces
grams->kilograms
grams->pounds

ounces->grams
kilograms->grams
pounds->grams

Now to convert pounds to kilograms you call:

pounds->grams
grams->kilograms

and you do not write a pounds->kilograms function.
Sep 16 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.