Results 1 to 13 of 13
  1. #1
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default 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

    Menu execution:
    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

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  3. #3
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default

    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

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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

  5. #5
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default

    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%

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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

  7. #7
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default

    thanks heaps :)
    i got it now
    i can move on to the fianl piece of my assignment yay

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  9. #9
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default

    im all Australian here :)

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by maknib View Post
    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!

  11. #11
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default 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:

    Java 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);
        }
      }
    
    }
    Last edited by ozzyman; 03-14-2011 at 10:47 PM.

  12. #12
    maknib is offline Member
    Join Date
    Nov 2010
    Posts
    90
    Rep Power
    0

    Default

    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

  13. #13
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

Similar Threads

  1. problem with java assignment
    By jaire in forum New To Java
    Replies: 9
    Last Post: 03-10-2011, 12:00 PM
  2. Problem with my assignment - in need of help!
    By Chopaan in forum New To Java
    Replies: 1
    Last Post: 01-17-2011, 03:19 AM
  3. assignment problem with List<T>
    By Newbie666 in forum New To Java
    Replies: 11
    Last Post: 01-21-2010, 01:12 PM
  4. The Assignment Problem
    By bumblyb33 in forum New To Java
    Replies: 5
    Last Post: 03-04-2009, 05:21 AM
  5. Replies: 8
    Last Post: 05-28-2008, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •