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

D | Question 14 9 pts The island nation of Balloo charges its ciizens an income

ID: 3910884 • Letter: D

Question

D | Question 14 9 pts The island nation of Balloo charges its ciizens an income tax each year. The tax rale is based on the following table amed Income 0-$9,000 0.000-$19.000 $29.999 30.000-539.99 40,000r more a A constructor that accepts and b. Am accessor method that validates the salary as being a positive value. c A matator method that denermines how moch tax an individual shovuld pay an instance represcnting the individual's salary. [I mark] II mark] 4 marks) d. Define the percentapes as class constants e. Declare any instance varisbles that you think are necessary for this class I mark ] (2 mark] Question 15 8 pts

Explanation / Answer

Hi, Written code to solve this problem you just create the class with name IncomeTax.java and write that code in it you will get the desired output if you like that give thumbs up !!! and if you have any doubts please let me know

.......................................................................................................................................................................................

//package IncomeTax;

import java.util.*;

public class IncomeTax {

int salary;

public static final int taxrate[] = {0,2,3,4,5};

public IncomeTax(int salary) {

this.salary = salary;

// TODO Auto-generated constructor stub

}

public static void main(String[] args) {

System.out.println("enter the salary...");

Scanner obScanner = new Scanner(System.in);

int salary = obScanner.nextInt();

IncomeTax obIncomeTax = new IncomeTax(salary);

int validated_salary=obIncomeTax.getSalary();

obIncomeTax.setSalary(validated_salary);

}

public int getSalary() {

if (salary >= 0) {

System.out.println("salary is valid");

}else {

System.out.println("Salary is invalid please enter valid positive integer");

}

return salary;

}

public void setSalary(int salary) {

int taxamount;

this.salary = salary;

if(salary >= 0 && salary <= 9000) {

System.out.println("your tax rate is " + taxrate[0] + "%" );

taxamount = (salary*taxrate[0])/100;

System.out.println("tax amount that need to pay is - " + taxamount);

}else if (salary >= 9001 && salary <= 9999) {

System.out.println("No taxrate in database for this amount hence cant calculate tax amount");

}else if(salary >= 10000 && salary <= 19000) {

System.out.println("tax rate is " + taxrate[1] + "%" );

taxamount = (salary*taxrate[1])/100;

System.out.println("tax amount that need to pay is - " + taxamount);

}else if (salary >= 19001 && salary <= 19999) {

System.out.println("No taxrate in database for this amount hence cant calculate tax amount");

}else if(salary >= 20000 && salary <= 29999) {

System.out.println("tax rate is " + taxrate[2] + "%" );

taxamount = (salary*taxrate[2])/100;

System.out.println("tax amount that need to pay is - " + taxamount);

}else if(salary >= 30000 && salary <= 39999) {

System.out.println("tax rate is " + taxrate[3] + "%" );

taxamount = (salary*taxrate[3])/100;

System.out.println("tax amount that need to pay is - " + taxamount);

}else if(salary >= 40000 ) {

System.out.println("tax rate is " + taxrate[4] + "%" );

taxamount = (salary*taxrate[4])/100;

System.out.println("tax amount that need to pay is - " + taxamount);

}

}

}