File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes asking about usuage of if with profit calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "asking about usuage of if with profit calculation" Watch "asking about usuage of if with profit calculation" New topic
Author

asking about usuage of if with profit calculation

kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
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

Joined: Jul 22, 2000
Posts: 9052
    
  12
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.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

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.


Please ignore post, I have no idea what I am talking about.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5018
    
    8

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


Junilu - [How to Ask Questions] [How to Answer Questions]
William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

Maybe this is closer to answering your question. Some sudo-code:
kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
hi there,
hope u ppl r doin fine.thanks alot for ur replies.
take care
with regards
kumar abhay
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: asking about usuage of if with profit calculation