473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
3 6692
code green
1,726 Expert 1GB
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
whodgson
542 512MB
.....and a 4th one
Expand|Select|Wrap|Line Numbers
  1. yes_no();/*might be worth while also*/
Sep 14 '10 #3
weaknessforcats
9,208 Expert Mod 8TB
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

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

Similar topics

12
by: Sammy | last post by:
Hi, my mind is going crazy. I have tried everything I can think of to no avail. I have tried Disable Output Escaping. I tried to think of a way of enclosing the attribute data in a CDATA...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
1
by: charles | last post by:
when i read the notable book of inside the c++ bject model ,i was confused by the chapter 3.3. i was confused by the statement as follow: chaper 3.3: Given the following pair of program...
27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
20
by: William | last post by:
Original question: "Give a one-line C expression to test whether a number is a power of 2. " Answer: if (x && !(x & (x-1)) == 0) My question: Why does this expression work?
17
by: orekinbck | last post by:
Hi There Say I want to check if object1.Property1 is equal to a value, but object1 could be null. At the moment I have code like this: if (object1 != null) { if (object1.Property ==...
0
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, ...
3
by: gg | last post by:
I specify the Url element as <xsd:element name="Url"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="512"/> <xsd:pattern value="http://+"/> </xsd:restriction>...
10
by: CDFTim | last post by:
O.K. that was a long Title... Can you help / show me how I would......... I am going to long windedly try to paint this picture. Backround: I have an html page that has a marquee function in it to...
1
by: VaidehiPawar | last post by:
I am a beginner level in xml..my output page does not convert &gt &lt it shows something like this " &lt;b&gt;Location.&lt;/b&gt;&lt;br /&gt; &lt;UL&gt;&lt;LI&gt;Park Central New York " can anyone help? here is my code ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.