i just started the course but teacher gave me this amazingly hard question for to start with he said it's some sort of challenge question im not just asking you for the answer but i think i need LOTS of
// The "Taxesforresidents" class.
public class Taxesforresidents
// The "Taxesforresidents" class.
public class Taxesforresidents
{
public static void main (String[] args)
{
System.out.println ("Enter the icome");
double income = ReadLib.readDouble ();
System.out.println ("Enter the housing cost");
double housingCost = ReadLib.readInt ();
System.out.println ("Enter the number of children");
int childTotal = ReadLib.readInt ();
System.out.println ("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 Taxesforresidents class
i hope someone help me with this question so here is the 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
and here is the ReadLib
// The "ReadLib " class by R.Parteno February 2001
// ReadLib is a library class of read routines all based upon pressing the enter key
// ReadLib provides methods for reading int, double, boolean, char and String types
import java.io.*;
import java.util.*;
public class ReadLib
{
// the Tokenizer is used to get the first item typed on a line, used with
// readInt(), readDouble(), and readBoolean()
static private StringTokenizer stok;
// the BufferedReader opens the connection to the keyboard
static private BufferedReader br
= new BufferedReader (new InputStreamReader (System.in));
public static int readInt () // uses a Tokenizer and Integer wrapper class
{ // to get a true int value
int i;
try
{
String str = br.readLine ();
StringTokenizer stok = new StringTokenizer (str);
i = new Integer (stok.nextToken ()).intValue ();
}
catch (IOException ex) // connection failure
{
System.out.println (ex);
i = 0;
}
catch (NumberFormatException nfe) // invalid keyboard entry
{
System.out.println ("Warning: A non-numeric value was entered");
System.out.println ("Your variable has been given value of 0");
i = 0;
}
return i;
}
public static double readDouble ()// uses a Tokenizer and Double wrapper class
{ // to get a true double value
double d = 0;
try
{
String str = br.readLine ();
stok = new StringTokenizer (str);
d = new Double (stok.nextToken ()).doubleValue ();
}
catch (IOException io)
{
System.out.println (io);
}
catch (NumberFormatException nfe)
{
System.out.println ("Warning: A non-numeric value was entered");
System.out.println ("Your variable has been given value of 0");
d = 0;
}
return d;
}
public static boolean readBoolean () // reads a boolean, looks for trus or false
{ // assumes false otherwise
boolean result = false;
try
{
String str = br.readLine ();
stok = new StringTokenizer (str);
String answer = stok.nextToken ();
if (answer.equals ("true")) // valid true entry
{
result = true;
}
else
{
if (!answer.equals ("false")) // invalid entry
System.out.println ("An invalid value was entered, false ia assumed");
result = false;
}
}
catch (IOException io)
{
System.out.println (io);
}
return result;
}
public static char readChar ()
{
char oneChar = ' ';
try
{
String str = br.readLine ();
oneChar = str.charAt (0); // oneChar is first character of keyboard entry
}
catch (IOException io) // connection error
{
System.out.println (io);
}
catch (StringIndexOutOfBoundsException se) // enter key only, no character
{
System.out.println ("There was no character entered, blank assumed");
}
return oneChar;
}
public static String readString ()
{
String str="";
try
{
str = br.readLine (); // returns null if no characters typed
}
catch (IOException io)
{
System.out.println (io);
}
return str;
}
} // ReadLib class