Motor - 802 Int Void Void Washmachine - 802 Motor - 802 Void System Void System
Motor - 802 Int Void Void Washmachine - 802 Motor - 802 Void System Void System
RollNo. 2005802
CSE-19
WT LAB ASSIGNMENT-5
1. Define an interface Motor with a data member –capacity and two methods such as run() and
consume(). Define a Java class ,Washing machine‟ which implements this interface and write the
code to check the value of the interface data member through an object of the class.
CODE:
interface motor_802{
int cap_802=100;
public void run();
public void consume();
}
class washMachine_802 implements motor_802{
public void run(){
System.out.println("Running "+cap_802);
}
public void consume(){
System.out.println("Consuming "+cap_802);
}
}
class washingMachine{
public static void main(String[] args){
motor_802 obj=new washMachine_802();
obj.run();
obj.consume();
}
}
OUTPUT:
2. Define an interface with three methods – earnings(), deductions() and bonus() and
define a Java class ,Manager‟ which uses this interface without implementing bonus() method. Also
define another Java class ,Substaff‟ which extends from ,Manager‟ class and implements bonus()
method. Write the complete program to find out earnings, deduction and bonus of a Substaff with
basic salary amount entered by the user as per the following guidelines – earnings basic + DA (80%
of basic) + HRA (15% of basic) deduction PF 12% of basic bonus 50% of basic.
CODE:
interface Emp_802{
int basic_802 = 5000;
double da_802 = 0.8;
double hra_802 = 0.15;
double pf_802 = 0.12;
double bonus = 0.5;
double earnings();
double deductions();
double bonus();
}
OUTPUT:
--END--
2005802
30/03/22