my assignment is simple really. someone enter a number for their income, if its under 9000, its taxed at 10%, over that, its 15% etc.
but then one of the requirements says "you will organize the income ranges as an array in each method and select an array record to compute specific tax in a tax bracket"
how would that work? doesn't array only take specific values and not ranges of values??
this is my code so far
public static int calcTax(int status, int income)
{
if (status == 0)
{
return singleFiling(income);
}
if (status == 1)
{
return jointFiling(income);
}
if (status == 2)
{
return headFiling(income);
}
else
System.out.println("Error: invalid status. Enter a number between 0 to 2 only.");
return income;
}
static int ninek = 9075;
static int thrirtysixk = 36900;
static int eightyninek = 89350;
static int oneeightysixk = 186350;
static int fourofivek = 405100;
static int fourosixk = 406750;
static int eighteenk = 18150;
static int seventythreek = 73800;
static int onefortyeightk = 148850;
static int twotwentysixk = 226850;
static int fourfivesevenk = 457600;
static int twelveninefifty = 12950;
static int fourninek = 49400;
static int onetwentysevenk = 127550;
static int twoosixk = 206600;
static int fpurthreetwok = 432200;
static double tax = 0;
static int singleFiling(double userIncome)
{
if (userIncome >= 1 && userIncome <= ninek )
tax = userIncome * 0.10;
System.out.println("Your payable Federal tax is: " + tax);
return 0;
}
static int jointFiling(double userIncome)
{
if (userIncome >= 1 && userIncome <= oneeightysixk )
tax = userIncome * 0.10;
System.out.println("Your payable Federal tax is: " + tax);
return 0;
}
static int headFiling(double userIncome)
{
if (userIncome >= 1 && userIncome <= twelveninefifty )
tax = userIncome * 0.10;
System.out.println("Your payable Federal tax is: " + tax);
return 0;
}
}
arrayand calculate thetaxregardingarray indexand store thetaxinto thatarray index