Page 112 - CTS - CSA TP - Volume 2
        P. 112
     COMPUTER SOFTWARE APPLICATION - CITS
           TASK 3: Updating Employee Salary
              class Employee {
                  String name;
                  double salary;
                  Employee(String name, double salary) {
                      this.name = name;
                      this.salary = salary;
                  }
                  // Method to raise the salary of an employee by a given percentage
                  void raiseSalary(double percentage) {
                      double raiseAmount = salary * (percentage / 100);
                      salary += raiseAmount;
                  }
              }
              public class RaiseSalaryDemo {
                  public static void main(String[] args) {
                      // Create an Employee object
                      Employee emp = new Employee(“John”, 50000);
                      // Print current salary
                      System.out.println(“Current salary of “ + emp.name + “: “ + emp.salary);
                      // Call the method to raise the salary by 10%
                      emp.raiseSalary(10);
                      // Print updated salary
                      System.out.println(“Updated salary of “ + emp.name + “: “ + emp.salary);
                  }
              }
            Output:
                                                           97
                                CITS : IT & ITES - Computer Software Application - Exercise 95
     	
