Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Just stuck I cannot figure out where my problem is it will not run. I have warni

ID: 3628015 • Letter: J

Question

Just stuck

I cannot figure out where my problem is it will not run. I have warnings on lines 14 & 15

import java.util.Scanner;
public class Income {

public static void main(String[] args){
/*
* This program will demonstrate the use of a grading scale
*
*/
String item;
double taxtable;
boolean Taxable = true;


while (Taxable)
{
System.out.print("Please enter your salary so I can calculate the tax");

Scanner keyboard = new Scanner(System.in);
taxtable = keyboard.nextInt();}
}


public double TaxRates;

public Income(double income, int salary) {
if (salary >= 0 && salary <= 8500) // 10%
TaxRates = income * .10;

else if (salary >= 8501 & salary <= 35000) //15%
TaxRates =(8500 * .10) + (salary-35000) * .15;

else if (salary >= 35001 && salary <= 80000) //25%
TaxRates =(8500 * .10) + (35000 * .15) + (salary-35000) * .25;

else if (salary >= 80001 && salary <= 170000) //28%
TaxRates =(8500 * .10) + (35000 * .15) + (80000 * .25) + (salary-80000 * .28);

else if (salary >= 170000) //33%
TaxRates =(8500 * .10) + (35000 * .15) + (80000 * .25) + (170000 * .28) + (salary-170000) * .33;

}
public double getIncomeTax() {
return TaxRates;
}
}

Explanation / Answer

You code is full of errors. 1. while(Taxable) will always true, and that makes the loop infinite. 2. it is easily to compute the salary by calling a function instead of creating a constructor 3. Scanner is only input a salary, what about the income? 4. getIncomeTax() are not doing anything. 5. no output printout? I only need to know "(double income, int salary)" , where did you get the income from?