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.
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?
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.
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
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:
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.