Problem working out Assignment

• 03-13-2011, 12:38 PM
maknib
Problem working out Assignment
Hi guys, not really a java problem.. but i'm stuck and wondering if i can get some help.

im 1/3 way through my assignment and the next criteria is as follows

Quote:

The program must allow the user to enter the following information:

**Your program should prompt the user to enter a number (with or without decimals) via the keyboard and then proceed to calculate the stamp duty payable. The result should then be displayed to the user in an easy to read format.
**The stamp duty brackets you will need to use are listed below.

Purchase Amount Percentage
< \$20,000 1.4% of dutiable value
\$20,001 - \$115,000 + 2.4% of dutiable value (added to the previous amount)
\$115,001 - \$870,000 + 6% of dutiable value (added to the previous amount)
> \$870,000 5.5% of dutiable value
My problem is i don't understand this Stamp duty. i've look around on the net and all i find is Calculators..

Does anyone know how to work out stamp duty?
according to one website.. \$300,000 value by these vigures should be about \$13,000 stamp duty but i still cant figure it out..
i thought it would be 300,000 / 6% + (whatever previous amount is).. what is this previous amount?

if you can help it would be great

thanks
• 03-13-2011, 12:53 PM
Fubarable
This is nothing more than some if blocks and simple arithmetic. Can you work out how you'd calculate this on paper? If so, then try to translate this code into Java. If you're still stuck, post in pseudo-code what you think the logical steps should be.
• 03-13-2011, 01:13 PM
maknib
thanks.

i know it's in if statments but it's the working out of Stamp duty im having trouble with. like the math for it

im thinking if the value was \$110,000
20k would be processed at 1.4 % and the rest would be processed at 2.4% + the duty from the 20k
• 03-13-2011, 01:19 PM
Fubarable
OK, say you enter \$30,000, then

First \$20,000 is processed at 1.4% rate, 20,000 * 0.014 = 280

Then the rest, \$30,000 - \$20,000 (in other words, \$10,000) is processed at the 2.4% rate, \$10,000 * 0.024 = 240

So the total tax would be 280 + 240 = \$520
• 03-13-2011, 01:23 PM
maknib
so is it oly the previous one..
if it was 140,000
would 20 get 1.4
115 get 2.4 and rest at 6% ?
or 115 at 2.4% and rest at 6%
• 03-13-2011, 01:29 PM
Fubarable
If it was 140, then:
20 taxed at 1.4% rate
115 - 20 (95) taxed at 2.4% rate
140 - 115 (25) taxed at 6% rate

Then add up all the taxes
• 03-13-2011, 02:12 PM
maknib
thanks heaps :)
i got it now
i can move on to the fianl piece of my assignment yay
• 03-13-2011, 02:14 PM
Fubarable
Great. And good luck. Note that if you live in the USA, you'd better understand this tax system well as it is similar to how the USA calculates individual federal income tax.
• 03-13-2011, 02:28 PM
maknib
im all Australian here :)
• 03-13-2011, 02:36 PM
Fubarable
Quote:

Originally Posted by maknib
im all Australian here :)

Per Wikipedia, Australia also uses a similar progressive tax on personal income, so this knowledge will come in handy, even for those living down under. Cheers!
• 03-13-2011, 03:29 PM
ozzyman
Hi
What I would do is create an Enum class for the tax percentages so that they can be easily changed without looking at your main code and then read the tax percent from those. I've written something for you as an example but I havent tested if it works or not:

Code:

```public enum TaxRates {   TAX_RATE_1(0,1.4),   TAX_RATE_2(20001,2.4),   TAX_RATE_3(115001,6),   TAX_RATE_4(870000,5.5);   public double minBound;   public double addedTaxPercent;   public TaxRates(double minBound, double addedTaxPercent) {     this.minBound = minBound;     this.addedTaxPercent = addedTaxPercent;   } } class CalculateTax {   public double getTax(double purchaseAmount) {     double totalTax = 0;     for (TaxRates t:TaxRates.values()) {       taxableAmount = purchaseAmount - t.minBound;       taxAmount = taxableAmount*(t.addedTaxPercent/100);       totalTax += taxAmount;     }     return totalTax;   }   public static main(String args[]) {     if (args.length > 1) {       System.out.println("Usage: java CalculateTax [number] e.g. java CalculateTax 100000");       System.exit(0);     } else {       double inputAmount = Double.parseDouble(args[0]);       double tax = getTax(inputAmount);       System.out.printf("The tax amount on AU\$%.2f is AU\$%.2f",inputAmount,tax);     }   } }```
• 03-14-2011, 04:04 AM
maknib
Thanks but as i said we are in Week 2 of Java. just covering If statements and switches.. i have no idea what an ENUM class is yet :P
• 03-14-2011, 10:50 PM
ozzyman
Ah, I see. Well good luck.