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

I am having trouble creating a tester class for this program: package taxcalcula

ID: 3639975 • Letter: I

Question

I am having trouble creating a tester class for this program:



package taxcalculator;

import java.util.Scanner;

public class TaxCalculator
{
private double income=0.0;
public TaxCalculator(double income){this.income=income;}
public double getTax()
{
double Tax=0.0;
if(income<=50000) Tax = income*0.01; else
if(income<=75000) Tax = income*0.02; else
if(income<=100000) Tax = income*0.03; else
if(income<=250000) Tax = income*0.04; else
if(income<=500000) Tax = income*0.05; else
Tax = income*0.06;
return Tax;
}
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.print("Please enter your income: ");
double income = in.nextDouble();
TaxCalculator T = new TaxCalculator(income);
System.out.println("Tax: " + T.getTax());
}
}

Explanation / Answer

package taxcalculator;

import java.util.Scanner;

public class TaxCalculator
{
private double income=0.0;
public TaxCalculator(double income){this.income=income;}
public double getTax()
{
double Tax=0.0;
if(income<=50000) Tax = income*0.01; else
if(income<=75000) Tax = income*0.02; else
if(income<=100000) Tax = income*0.03; else
if(income<=250000) Tax = income*0.04; else
if(income<=500000) Tax = income*0.05; else
Tax = income*0.06;
return Tax;
}

}

package taxcalculator;

import java.util.Scanner;

public class TestTax
{

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Please enter your income: ");

try{
double income = in.nextDouble();
TaxCalculator T = new TaxCalculator(income);
System.out.println("Tax: " + T.getTax());

} catch (Exception e) {

System.out.println(" Enter valid amount in digits..");

}

}

}