• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

asking about usuage of if with profit calculation

 
kumar abhay
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
i hope u ppl r doin' fine.mu question is taht suppose if i have int=200000 then from it on first 50000 there should be no tax ,given below:
200000-50000=0 tax
150000-20000=10% tax
130000-30000=20% tax
100000-50000=25% tax
50000 30% tax

i tried a little so the programme given below:


i hope u ppl will help me out.
take care
with regards
kumar abhay

[This message has been edited by Marilyn deQueiroz (edited November 06, 2001).]
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kumar abhay,
You have been around JavaRanch for a little while now. In fact you are almost a ranch hand. We are happy you are here.

It would be courteous if you would use code tags on your code. It would make your code easier to read. Also it would be a good example for the newer people posting here.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To start out lets unconfuse things. The number of zeros in the definitions seems to be incorrect. You have:
200,000 to 50,000 = no tax
I assume you mean
20,000 to 50,000 = no tax
And than the next line you say:
100,000 to 20,000 = 10% tax
Which is confusing in more than one way. Is the value of 100,000 a typo for 10,000?
Even accounting for typos the ranges don't match up.
In the code you have variable names like e, f, g which are never used. I know that it isn't a large program but is doesn't help when you are trying to read the code.
You also need to use curly brackets for your ifs.
Give it another try and post back again, thanks.
 
Junilu Lacar
Bartender
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar,
Is this the taxation scheme you are trying to explain?
first 50000, no tax
next 20000 (amount from 50001 to 70000), taxed at 10%
next 30000 (amount from 70001 to 100000), taxed at 20%
next 50000 (amount from 100001 to 150000), taxed at 25%
remainder (amount from 150001 and above), taxed at 30%
If this is the case, try using an appropriate loop and two arrays: one to hold the scale, one to hold the corresponding percentages.
I'm giving you a hint only in case this is a class assignment.
HTH,
Junilu
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this is closer to answering your question. Some sudo-code:
 
kumar abhay
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
hope u ppl r doin fine.thanks alot for ur replies.
take care
with regards
kumar abhay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic