ESc101 Laboratory Assignment Thursday 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. Deposit, SimpleInterest, CompoundInterest, and ProgramClass. The classes SimpleInterest and CompoundInterest are sub classes of class Deposit. The class Deposit has DepositNumber, AccountHolder, Amount, RateOfInterest, NumOfYears as member data and a member function ComputeInterest.The function ComputeInterest is overridden in classes SimpleInterest and ComputeInterest. It calculates the Interest depending on the Interest Calculation Method : Simple Interest or Compound Interest. In the ProgramClass, write code to take information about 10 Deposits as input from the user including information about whether the interest should be calculated as Simple Interest or Compound Interest, compute respective objects, and save them in a single array. Compute the Interest for each deposit depending on its type using a loop. Then display the Interest calaculated for each deposit. ====================================================================================