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

1.Create a Java program to implement the salary and tax paying methods and main

ID: 3670827 • Letter: 1

Question

1.Create a Java program to implement the salary and tax paying methods and main method should implement objects (if needed). There should be minimum four methods and return type int, String and void should be used. Also try to use static key word for a method. (NOTE: Apply salary and tax calculating techniques by your own)

2.Create a java program to implement the shopping list and price calculation by using all the constructors (parameterized constructors) and methods concept.

3. Implement the second program by invoking current class constructor.

Explanation / Answer

/**
* @author srinu
*
*/
public class EmployeeTax {
   String empName;
   int empID;
   float salary;

   /**
   *
   */
   public EmployeeTax() {
       // TODO Auto-generated constructor stub
   }

   /**
   * @param empName
   * @param empID
   * @param salary
   */
   public EmployeeTax(String empName, int empID, float salary) {
       super();
       this.empName = empName;
       this.empID = empID;
       this.salary = salary;
   }

   /**
   * @return the empName
   */
   public String getEmpName() {
       return empName;
   }

   /**
   * @param empName
   * the empName to set
   */
   public void setEmpName(String empName) {
       this.empName = empName;
   }

   /**
   * @return the empID
   */
   public int getEmpID() {
       return empID;
   }

   /**
   * @param empID
   * the empID to set
   */
   public void setEmpID(int empID) {
       this.empID = empID;
   }

   /**
   * @return the salary
   */
   public float getSalary() {
       return salary;
   }

   /**
   * @param salary
   * the salary to set
   */
   public void setSalary(float salary) {
       this.salary = salary;
   }

   /**
   * @param salary
   * @return
   */
   public double calcTax() {
       double taxableInc;
       double Tax = 0;
       taxableInc = salary * 80 / 100;
       if (taxableInc <= 15000) {
           Tax = taxableInc * 10 / 100;
       }

       else if (taxableInc > 15000 && taxableInc <= 20000) {
           Tax = (taxableInc - 15000) * 20 / 100 + (15000 * 10 / 100);

       }
       if (taxableInc > 35000) {
           Tax = (taxableInc - 35000) * 25 / 100 + (15000 * 10 / 100)
                   + (20000 * 20 / 100);
       }
       return Tax;
   }

   /*
   * (non-Javadoc)
   *
   * @see java.lang.Object#toString()
   */
   @Override
   public String toString() {
       return "EmployeeTax [empName=" + empName + ", empID=" + empID
               + ", salary=" + salary + "]";
   }

   /**
   * @param args
   */
   public static void main(String[] args) {

       try {

           EmployeeTax employeeTax = new EmployeeTax("Srinvas", 233, 55000);
           System.out.println("Employee:" + employeeTax);
           System.out.println("Tax is:" + employeeTax.calcTax());

       } catch (Exception e) {
           // TODO: handle exception
       }

   }
}

OUTPUT:

Employee:EmployeeTax [empName=Srinvas, empID=233, salary=55000.0]
Tax is:7750.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote