can you help me with this java programming?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 9107you
    New Member
    • Mar 2008
    • 1

    #1

    can you help me with this java programming?

    I just started the course and this crazy teacher wants me to do this hard ass question

    The government of Mississauga has asked you to write a program that would calculate taxes for Mississauga residents. Your program should ask for the income (income) housing cost (housingCost), number of children (childTotal), and the total number of children in school (schoolChildren ). It should then compute and print the tax payable or the refund due. The following are the tax regulations: the municipal tax rate is 19% but residents are not taxed on the first $15000 unless they pay more than $6000 for housing. For every child, residents get a $350 reduction, or $670 if the child is in school. This reduction never results in residents getting refunds unless their housing costs are less than $5800 and they have more than 2 children, at least one of them in school. If the tax payable is more than $1800, then it is increased by an additional 15% surtax.

    an output window with the following inputs:


    3 children with 1 child in school
    35000 income
    5999 house cost

    this is what i have
    // The "Taxesforreside nts" class.
    public class Taxesforresiden ts
    {
    public static void main (String[] args)
    {
    System.out.prin tln ("Enter the icome");
    double income = ReadLib.readDou ble ();

    System.out.prin tln ("Enter the housing cost");
    double housingCost = ReadLib.readInt ();

    System.out.prin tln ("Enter the number of children");
    int childTotal = ReadLib.readInt ();

    System.out.prin tln ("Enter the total number of children in school");
    int schoolChildren = ReadLib.readInt ();

    if (housingCost <= 600000) income -= 1500000;

    if (income < 0) income = 0;

    double tax = taxableIncome * 19 / 100;
    tax -= 35000 * childTotal;
    tax -= (67000-35000) * schoolChildren;

    if (tax < 0 && (housingCost > 580000 || childTotal < 3 || schoolChildren == 0)) tax = 0;

    if (tax > 180000) tax += income * 15 / 100;
    return tax;
    }



    } // end of main method
    } // end of Taxesforresiden ts class
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by 9107you
    I just started the course and this crazy teacher wants me to do this hard ass question

    The government of Mississauga has asked you to write a program that would calculate taxes for Mississauga residents. Your program should ask for the income (income) housing cost (housingCost), number of children (childTotal), and the total number of children in school (schoolChildren ). It should then compute and print the tax payable or the refund due. The following are the tax regulations: the municipal tax rate is 19% but residents are not taxed on the first $15000 unless they pay more than $6000 for housing. For every child, residents get a $350 reduction, or $670 if the child is in school. This reduction never results in residents getting refunds unless their housing costs are less than $5800 and they have more than 2 children, at least one of them in school. If the tax payable is more than $1800, then it is increased by an additional 15% surtax.

    an output window with the following inputs:


    3 children with 1 child in school
    35000 income
    5999 house cost

    this is what i have
    // The "Taxesforreside nts" class.
    public class Taxesforresiden ts
    {
    public static void main (String[] args)
    {
    System.out.prin tln ("Enter the icome");
    double income = ReadLib.readDou ble ();

    System.out.prin tln ("Enter the housing cost");
    double housingCost = ReadLib.readInt ();

    System.out.prin tln ("Enter the number of children");
    int childTotal = ReadLib.readInt ();

    System.out.prin tln ("Enter the total number of children in school");
    int schoolChildren = ReadLib.readInt ();

    if (housingCost <= 600000) income -= 1500000;

    if (income < 0) income = 0;

    double tax = taxableIncome * 19 / 100;
    tax -= 35000 * childTotal;
    tax -= (67000-35000) * schoolChildren;

    if (tax < 0 && (housingCost > 580000 || childTotal < 3 || schoolChildren == 0)) tax = 0;

    if (tax > 180000) tax += income * 15 / 100;
    return tax;
    }



    } // end of main method
    } // end of Taxesforresiden ts class

    Please post your code in tags...

    Below return tax, right brace is not necessary...

    What is ReadLib? is ReadLib implemented in DataInputStream ? you forgot to initialize it...

    variable taxableIncome, you forgot to initialize it too...

    If you like to return a value from a method, change the void input to a datatype that represents the data you like to return... since tax is a double, then change the void with it....

    Since that is in method main, make another method, put the operations there and call that method in method main... or you can construct a constructor and call it in method main...


    Another way to catch the input is to use Scanner class ... this may fit your needs...

    i hope it helps,
    Sukatoa
    Last edited by sukatoa; Mar 2 '08, 02:47 AM. Reason: addition

    Comment

    Working...