Please Help me in c++ programming

Discussion in 'C++' started by Umairajmal, Dec 25, 2010.

  1. Umairajmal

    Umairajmal New Member

    Joined:
    Dec 12, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hazro,Pakistan
    Home Page:
    http://www.facebook.com/m.umairajmal
    Hi, guys i am umair. i am a beginer programmer in c++ and i have a problem. I want to add two old style British corrency(i.e, Pounds.Shillings.Pence e.g, 10.2.13). please tell me how can i do this.
    Please help me...................
    I will be very thankful to you.
     
  2. Programming_Kills

    Programming_Kills New Member

    Joined:
    Jun 14, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Can you please Explain What Actually you Want???
     
  3. Umairajmal

    Umairajmal New Member

    Joined:
    Dec 12, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hazro,Pakistan
    Home Page:
    http://www.facebook.com/m.umairajmal
    Actually i want to make aprogramme that can add two old style British curency.The question is:

    creat a programme that allow a user to enter two values in old style british curency and program should add them.
    the old style british curency is:
    pound.shilling.pence(e.g, 13.10.19)
    in this situation
    pound = 12s hillings.
    shilling = 20 pence.
    Please help me if u can?
     
  4. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
    What have you tried?

    Please post your code.

    Jim
     
  5. Umairajmal

    Umairajmal New Member

    Joined:
    Dec 12, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hazro,Pakistan
    Home Page:
    http://www.facebook.com/m.umairajmal
    sorry guys i am very busy in these days and i does not see my post.
    My question is that i want to add two values of old style british corrency.
    Plz tell me the formula for adding.
     
  6. jimblumberg

    jimblumberg New Member

    Joined:
    May 30, 2010
    Messages:
    120
    Likes Received:
    29
    Trophy Points:
    0
    What have you tried?

    Post the code showing that you are trying.

    This is your assignment and you must first show a good faith effort at completing your assignment before we will help.

    Jim
     
  7. ThorAsgard

    ThorAsgard New Member

    Joined:
    Feb 16, 2010
    Messages:
    9
    Likes Received:
    3
    Trophy Points:
    0
    Location:
    Somerset,UK
    Is this the formula you mean

    So there were 240d (that's pence) in £1 that's 12 (pence in a shilling) x 20 (shillings in a pound) - easy isn't it?

    :happy:
     
    Umairajmal likes this.
  8. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    You can do it two ways:

    (1) you can write functions to convert between LSD and a number of D (for example 13.3.9 would be 13*240+3*12+9=3165), then for the two amounts you want to add, convert them to D, add the D sums together just using normal integer arithmetic and convert the result back, or

    (2) you can add individual D values together and handle any overflow into the S calculation, then likewise for S and D, i.e.
    D=D1+D2; if D>11 split into D<12 and overflow F;
    S=S1+S2+F; if S>19 split into S<20 and overflow F;
    L=L1+L2+F.

    I would suggest (1), not because it's easier in the short run, but because sooner or later you are going to need these functions, so you may as well write them in the first instance then you can use them straight away.
     
    Umairajmal likes this.
  9. Umairajmal

    Umairajmal New Member

    Joined:
    Dec 12, 2010
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Hazro,Pakistan
    Home Page:
    http://www.facebook.com/m.umairajmal
    thanks to all of you to tell me what i do for this problem.
    Thanks again.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice