Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   Please Help me in c++ programming (http://www.go4expert.com/forums/help-cpp-programming-t24259/)

Umairajmal 25Dec2010 11:10

Please Help me in c++ programming
 
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.

Programming_Kills 25Dec2010 14:57

Re: Please Help me in c++ programming
 
Can you please Explain What Actually you Want???

Umairajmal 25Dec2010 19:59

Re: Please Help me in c++ programming
 
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?

jimblumberg 26Dec2010 00:58

Re: Please Help me in c++ programming
 
What have you tried?

Please post your code.

Jim

Umairajmal 29Dec2010 15:19

Re: Please Help me in c++ programming
 
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.

jimblumberg 29Dec2010 19:21

Re: Please Help me in c++ programming
 
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

ThorAsgard 29Dec2010 21:26

Re: Please Help me in c++ programming
 
Quote:

Originally Posted by Umairajmal (Post 76575)
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?

:happy:

xpi0t0s 29Dec2010 23:43

Re: Please Help me in c++ programming
 
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 5Feb2011 11:12

Re: Please Help me in c++ programming
 
thanks to all of you to tell me what i do for this problem.
Thanks again.


All times are GMT +5.5. The time now is 02:15.