ESc101 Laboratory Assignment Tuesday of Week of 1/11/04 The assignment consists of two parts A and B. In part A, you have to run the programs given and give explanation for the results obtained. In part B you have to write a Java Program. ======= PART A ======= 1) class A { private int i,j; A(int x, int y) { i = x; j = y; } A() { i = 0; j = 0; } void setA(int x, int y) { i = x; j = y; } int getAi() { return i; } int getAj() { return j; } } class B extends A { private int total; B() { total = 0; } void setTotal() { total = i + j; } int getTotal() { return total; } } class prog1 { public static void main(String args[]) { B obj = new B(); obj.setTotal(); System.out.println("\n Value of total = " + obj.getTotal()); } } ------------------------------------------------------------------------------ 2) class A { private int i,j; A(int x, int y) { i = x; j = y; } A() { i = 0; j = 0; } void setA(int x, int y) { i = x; j = y; } int getAi() { return i; } int getAj() { return j; } } class B extends A { private int total; B() { super(); total = 0; } B(int x, int y) { super(x,y); total = 0; } void setTotal() { total = getAi() + getAj(); } int getTotal() { return total; } } class prog2 { public static void main(String args[]) { B obj = new B(10,15); obj.setTotal(); System.out.println("\n Value of total = " + obj.getTotal()); } } ---------------------------------------------------------------------- 3) class superclass { int i; void calc(int x) { System.out.println("\n The value = " + (x+i)); } int getsuperi() { return i; } void setsuperi(int x) { i = x; } } class subclass extends superclass { int i; void calc(int x) { System.out.println("\n The value = " + (super.i + i + x)); } void calc(float x) { System.out.println("\n The value = " + (super.i * x + i)); } int geti() { return i; } void seti(int x) { i = x; } } class prog3 { public static void main(String args[]) { subclass ob = new subclass(); ob.seti(20); ob.setsuperi(35); superclass sup_obj = ob; sup_obj.calc(10); superclass obj2 = new superclass(); obj2.calc(4); } } -------------------------------------------------------------------- 4) Add the following statement to the main function in the above program after the last statement. Run the program and justify the outcome. sup_obj.calc((float)4.0); ================================================================================== PART B ======= Write a program with four classes. Employee, Manager, RegularEmployee, and ProgramClass. The classes Manager and RegularEmployee are sub classes of class Employee. The class Employee has name, EmpNo, Salary as member data and a member function ComputeIncrement(). The function ComputeIncrement is overridden in classes Manager and RegularEmployee. It calculates the increment in the salary depending on the employee type and updates the salary for the object. In the ProgramClass, write code to take information about 10 employees as input from the user and information about whether the employee is a Manager or a RegularEmployee, create respective objects and save them in a single array. Compute the increment in the salary for each employee using a loop. Then display the updated information about each employee. The increment is 10% of the salary for Regular Employee and is 30% of the salary for Manager.