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);
}
}
}
D | Question 14 9 pts The island nation of Balloo charges its ciizens an income...