0% found this document useful (0 votes)
4 views12 pages

Oops 3,4,5

Useful for practical

Uploaded by

Jenifer M
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)
4 views12 pages

Oops 3,4,5

Useful for practical

Uploaded by

Jenifer M
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/ 12

REGNO:311521205007

PROGRAM
package employee_details;
import java.util.Scanner;
class Employee{
String Emp_name;
int Emp_id;
String Address;
String Mail_id;
long Mobile_no;
void display(){
System.out.println(Emp_name);
System.out.println(Emp_id);
System.out.println(Mail_id);
System.out.println(Mobile_no);
}
}
class Programmer extends Employee{
int BP;
void display(){
System.out.println(BP);
System.out.println("DA"+0.97*BP);
System.out.println("HRA"+0.10*BP);
System.out.println("PF"+0.12*BP);
REGNO:311521205007

System.out.println("SATFF CLUD FUND"+0.001*BP);


}
}
class Assistant_Professor extends Employee{
int BP;
void display(){
System.out.println(BP);
System.out.println("DA"+0.97*BP);
System.out.println("HRA"+0.10*BP);
System.out.println("PF"+0.12*BP);
System.out.println("SATFF CLUD FUND"+0.001*BP);
}
}
class Associate_Professor extends Employee{
int BP;
void display(){
System.out.println(BP);
System.out.println("DA"+0.97*BP);
System.out.println("HRA"+0.10*BP);
System.out.println("PF"+0.12*BP);
System.out.println("SATFF CLUD FUND"+0.001*BP);
}
}
REGNO:311521205007

class Professor extends Employee{


int BP;
void display(){
System.out.println(BP);
System.out.println("DA"+0.97*BP);
System.out.println("HRA"+0.10*BP);
System.out.println("PF"+0.12*BP);
System.out.println("SATFF CLUD FUND"+0.001*BP);
}
}
public class employee_details {
public static void main(String[] args) {
System.out.println("\n
1.Programmer\n2.Assistant_Professor\n3.Associate_Professor\n4.Prof
essor");
Scanner input=new Scanner(System.in);
System.out.print("Enter an integer: ");
int ch=input.nextInt();
switch (ch) {
case 1:
Employee e1=new Employee();
Programmer p1=new Programmer();
e1.Emp_name="SUGHASHINI";
e1.Address="CHENNAI”;
REGNO:311521205007

e1.Mail_id="[email protected]
e1.Emp_id=001;
e1.Mobile_no=9689088765L;
p1.BP=15000;
p1.display();
e1.display();
break;
case 2:
Employee e2=new Employee();
Assistant_Professor p2=new Assistant_Professor();
e2.Emp_name="VISHWA";
e2.Address="THIRUTANI";
e2.Mail_id="[email protected]";
e2.Emp_id=002;
e2.Mobile_no=9873785215L;
p2.BP=30000;
p2.display();
e2.display();
break;
case 3:
Employee e3=new Employee();
Associate_Professor p3=new Associate_Professor();
e3.Emp_name="ANITHA";
REGNO:311521205007

e3.Address="CHENNAI";
e3.Mail_id="[email protected]";
e3.Emp_id=003;
e3.Mobile_no=9871797606L;
p3.BP=30000;
p3.display();
e3.display();
break;
case 4:
Employee e4=new Employee();
Professor p4=new Professor();
e4.Emp_name="SRIMATHI";
e4.Address="TRICHY";
e4.Mail_id="[email protected]";
e4.Emp_id=004;
e4.Mobile_no=9810578058L;
p4.BP=30000;
p4.display();
e4.display();
break;
case 5:
//exit(1);
default:
REGNO:311521205007

System.out.println("Enter correct choice:");


}
}
}
OUTPUT
REGNO:311521205007

PROGRAM
package area_of_shapes_abstractclass;
abstract class shape{
int x,y;
abstract void area(double x,double y);
}
class Rectangle extends shape{
void area(double x,double y){
System.out.println("Area of rectangle is:"+(x*y));
}
}
class Circle extends shape{
void area(double x,double y){
System.out.println("Area of circle is:"+(3.14*x*x));
}
}
class Triangle extends shape{
void area(double x,double y){
System.out.println("Area of triangle is:"+(0.5*x*y));
}
}
REGNO:311521205007

public class AREA_OF_SHAPES_ABSTRACTCLASS {


public static void main(String[] args) {
Rectangle r=new Rectangle();
r.area(6,2);
Circle C=new Circle();
C.area(11,11);
Triangle T=new Triangle();
T.area(2,8);
}
}

OUTPUT
REGNO:311521205007

PROGRAM
package area_of_shapes_using_interface;
interface Shape
{
void input();
void area();
}
class Circle implements Shape
{
int r = 0;
double pi = 3.14, ar = 0;
public void input()
{
r = 5;
}
public void area()
{
ar = pi * r * r;
System.out.println("Area of circle:"+ar);
}
}
class Rectangle extends Circle
{
int l = 0, b = 0;
double ar;
public void input()
{
super.input();
l = 6;
b = 4;
}
public void area()
{
super.area();
ar = l * b;
System.out.println("Area of rectangle:"+ar);
}
}
class Triangle implements Shape
{
int l = 0, b = 0;
double half = 0.5, ar = 0;
public void input()
{
l = 12;
b = 9;
REGNO:311521205007

}
public void area()
{
ar = half * l * b;
System.out.println("Area of triangle:"+ar);
}
}
public class AREA_OF_SHAPES_USING_INTERFACE {
public static void main(String[] args) {
Rectangle obj = new Rectangle();
Triangle obj1 = new Triangle();
obj.input();
obj.area();
obj1.input();
obj1.area();
}
}
OUTPUT

You might also like