0% found this document useful (0 votes)
192 views3 pages

Motor - 802 Int Void Void Washmachine - 802 Motor - 802 Void System Void System

1. The document describes two Java programming assignments. The first defines an interface Motor with methods run() and consume() and a class WashingMachine that implements this interface. It checks the interface data member value through an object. 2. The second defines an interface Emp with methods earnings(), deductions(), and bonus() and classes Manager and SubStaff. Manager implements the first two methods while SubStaff extends Manager and implements bonus(). The program calculates earnings, deductions, and bonus of a SubStaff using guidelines based on a basic salary entered by the user.

Uploaded by

Shreya Kishor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
192 views3 pages

Motor - 802 Int Void Void Washmachine - 802 Motor - 802 Void System Void System

1. The document describes two Java programming assignments. The first defines an interface Motor with methods run() and consume() and a class WashingMachine that implements this interface. It checks the interface data member value through an object. 2. The second defines an interface Emp with methods earnings(), deductions(), and bonus() and classes Manager and SubStaff. Manager implements the first two methods while SubStaff extends Manager and implements bonus(). The program calculates earnings, deductions, and bonus of a SubStaff using guidelines based on a basic salary entered by the user.

Uploaded by

Shreya Kishor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Ishaan Thakral

RollNo. 2005802
CSE-19

WT LAB ASSIGNMENT-5

INTERFACE JAVA CODES:


DATE: 23/03/22

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();
}

class Manager_802 implements Emp_802{


public double earnings() {
return basic_802 + (basic_802 * da_802) + (basic_802 * hra_802);
}
public double deductions() {
return basic_802 * pf_802;
}
public double bonus() {
return 0;
}
}
class SubStaff extends Manager_802{
public double bonus() {
return basic_802 * bonus;
}
}
class man{
public static void main(String[] args) {
System.out.println("The basic salary is :"+ Emp_802.basic_802);
SubStaff s = new SubStaff();
System.out.println("Earnings: "+s.earnings());
System.out.println("Deductions: "+s.deductions());
System.out.println("Bonus: "+s.bonus());
}
}

OUTPUT:
--END--
2005802
30/03/22

You might also like