// JAVA TEST CODES NO 4: MODIFY TEST CODES NO 3 /* This program modifies the employee class so it can display both the old and new salary after giving bonus. */ /* To test the program, save this file in your class folder as Employee.java. Compile using the command javac Employee.java then run the program using the command java Employee. */ public class Employee // Create employee class { // Employee attributes String name; float annualSalary = 40000f; float bonus; float weeklySalary; float oldSalary; // For saving old salary // Method to save old salary public void saveOldSalary() { oldSalary = annualSalary; } // Method to add bonus to salary public void addBonus(String employeeName, float employeeBonus) { name = employeeName; // Transfer passed value to class variable bonus = employeeBonus; annualSalary = annualSalary + bonus; } // Method to compute new weekly salary public void computeNewWeekly () { weeklySalary = annualSalary / 52; } public static void main(String args[]) // Main method { // Create an instance of employee Employee bonusEmployee = new Employee(); // First, save the old salary bonusEmployee.saveOldSalary(); // Call method to increase salary bonusEmployee.addBonus("Wilhelm Lim", 1000f); // Call method to compute new weekly bonusEmployee.computeNewWeekly(); // Print results System.out.println(); System.out.println("Employee Name: " + bonusEmployee.name); System.out.println(); System.out.println("Old Salary: " + bonusEmployee.oldSalary); System.out.println(); System.out.println("Bonus Given: " + bonusEmployee.bonus); System.out.println(); System.out.println("New Salary: " + bonusEmployee.annualSalary); System.out.println(); System.out.println("New Weekly: " + bonusEmployee.weeklySalary); } } /* This is just one way of solving the problem. You can have a different code as long as the output is correct. */