Please Help me in c++ programming

Umairajmal's Avatar, Join Date: Dec 2010
Go4Expert Member
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.
0
Programming_Kills's Avatar, Join Date: Jun 2010
Go4Expert Member
Can you please Explain What Actually you Want???
0
Umairajmal's Avatar, Join Date: Dec 2010
Go4Expert Member
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?
0
jimblumberg's Avatar
Ambitious contributor
What have you tried?

Please post your code.

Jim
0
Umairajmal's Avatar, Join Date: Dec 2010
Go4Expert Member
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.
0
jimblumberg's Avatar
Ambitious contributor
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
0
ThorAsgard's Avatar, Join Date: Feb 2010
Light Poster
Quote:
Originally Posted by Umairajmal View Post
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.
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?

Umairajmal like this
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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 like this
0
Umairajmal's Avatar, Join Date: Dec 2010
Go4Expert Member
thanks to all of you to tell me what i do for this problem.
Thanks again.