Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all , i have grand total and tax amount in %. now i want to show the tax value in number using C#.

i am getting small errors in getting actual values.

here is my code .


C#
decimal GrandTotal = 240.35;
decimal Taxfactor  =15 ; 

decimal taxamount= grandtotal - ((grandtotal * taxfactor)/100);


but taxamount
value gives me 36.0525 and actual tax amount should be 31.35.

coz what real data is subtotal = 209 plus tax 15% which gives 240.35.

i know it is because i calculate tax percentage on grandtotal but i dont know where i should modified.
Posted

Total = nett * ((100 + rate) / 100);
Tax = Total * (rate / (100 + rate));
 
Share this answer
 
v3
Comments
ravikhoda 25-Feb-14 2:47am    
i do not have the net amount with me that 's why i can't use this code.
[no name] 25-Feb-14 2:49am    
The second line is your answer nothing to do with nett.
ravikhoda 25-Feb-14 3:31am    
there is no rule that a team leader can not ask a question or he can no be wrong. its ok if you are not satisfied with my ans or whatever but you should respect other people when you answer about their questions...
[no name] 25-Feb-14 3:40am    
You had posted and accepted a wrong answer to your own question. Even after correction it still is not an efficient way of doing it. I took the trouble to provide you with a correct answer. You told me mine was unusable. I never criticise anyone for being wrong.
ravikhoda 25-Feb-14 3:50am    
anyways thanks for your help.
ok i have solve this my self


here is the code.


C#
decimal GrandTotal = 240.35;
decimal Taxfactor  =15 ; 
 
decimal taxamount=grandtotal - ((grandtotal *100)/100+Taxfactor  );
 
Share this answer
 
v2
Comments
[no name] 25-Feb-14 2:42am    
Not correct. Gives the nett.
ravikhoda 25-Feb-14 2:47am    
yes i modified my answer a bit, this will give me what i looking for.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900