Assignment 3
Assignment 3
//Problem Statement::
/*
Design and develop inheritance for a given case study, identify objects and relationships
and implement inheritance wherever applicable. Employee class has Emp_name, Emp_id,
Address, Mail_id, and Mobile_no as members. Inherit the classes: Programmer, Team Lead,
Assistant Project Manager and Project Manager from employee class. Add Basic Pay (BP) as
the member of all the inherited classes . with 97% of BP as DA, 10 % of BP as HRA, 12% of
BP as PF, 0.1% of BP for staff club fund. Generate pay slips for the employees with their
*/
import java.util.*;
class Employee {
id++;
void input() {
emp_id=id;
void display(){
System.out.println("***********************************************************
*****");
System.out.println("***********************************************************
*****");
System.out.println(emp_name+"\t\t"+emp_id+"\t"+address+"\t\t"+mobile_no +"\n");
void salary(){
da=basic_pay*.97;//calculating da
hra=basic_pay*.10;//calculating hra
pf=basic_pay*.12;//calculating pf
staff_club_fund=basic_pay*0.001;//calculating staff_club_fund
int k=0;
k=sc.nextInt();
gross_salary+=3000;
gross_salary+=2000;
break;
System.out.println("INVALID CHOICE.");
net_salary=gross_salary-pf-staff_club_fund;
System.out.println("===========================================================
======================");
void salary_slip() {
System.out.println("***********************************************************
*****");
System.out.println(" PF : "+pf);
System.out.println("***********************************************************
*****");
}
}
void read_programmer() {
input();
boolean a=false;
while(a==false) {
basic_pay=sc.nextDouble();
if(basic_pay>40000 || basic_pay<30000) {
a=false;
else
a=true;
System.out.println("===========================================================
======================");
for(int i=0;i<n;i++) {
if (arr[i].emp_id==key) {
else {
void read_teamlead() {
input();
boolean a=false;
while(a==false) {
basic_pay=sc.nextDouble();
if(basic_pay>50000 || basic_pay<40000) {
else
a=true;
System.out.println("===========================================================
======================");
for(int i=0;i<n;i++) {
if (arr[i].emp_id==key) {
else {
input();
boolean a=false;
while(a==false) {
basic_pay=sc.nextDouble();
if(basic_pay>60000 || basic_pay<50000) {
a=false;
else
a=true;
System.out.println("===========================================================
======================");
for(int i=0;i<n;i++) {
if (arr[i].emp_id==key) {
else {
void read_Pro_manager() {
input();
boolean a=false;
while(a==false) {
basic_pay=sc.nextDouble();
if(basic_pay>70000 || basic_pay<60000) {
a=false;
else
a=true;
System.out.println("===========================================================
======================");
if (arr.emp_id==key) {
else {
aa:
do {
System.out.print("Choice::");
System.out.println("===========================================================
======================");
int op;
int assign1=0,assign2=0,assign3=0,assign4=0;
switch(k) {
do {
System.out.print("\tPROGRAMMER MENU
.....\n\t1. INPUT \n\t2. DISPLAY \n\t3. EXIT FROM PROGRAMMER \n\tChoice::");
op=sc.nextInt();
System.out.println("===========================================================
======================");
assign1=6;
p[i]=new Programmer();
p[i].read_programmer();
p[i].salary();
//printing salary of Programmer
p[i].display();
p[i].salary_slip();
System.out.println("===========================================================
========================================");
}while(op!=3);
break;
do {
op=sc.nextInt();
System.out.println("===========================================================
========================================");
if(op==1)
assign2=4;
for (int i=0;i<3;i++) {
t[i]=new Teamlead();
t[i].read_teamlead();
t[i].salary();
t[i].display();
t[i].salary_slip();
System.out.println("===========================================================
========================================");
}while(op!=3);
break;
do {
op=sc.nextInt();
System.out.println("===========================================================
========================================");
if(op==1)
assign3=2;
a[i]=new Asst_pro_manager();
a[i].read_Asst_pro_manager();
a[i].salary();
a[i].display();
a[i].salary_slip();
System.out.println("===========================================================
========================================");
}while(op!=3);
break;
case 4://if input from user is 4
do {
op=sc.nextInt();
System.out.println("===========================================================
========================================");
if(op==1)
assign4=1;
m.read_Pro_manager();
m.salary();
m.display();
m.salary_slip();
System.out.println("===========================================================
========================================");
}while(op!=3);
break;
String des;
int key;
des=sc.next();
key=sc.nextInt();
if(des.toLowerCase().equals("programmer"))
Programmer.search(p,key,6);
else if(des.toLowerCase().equals("teamlead"))
else if(des.toLowerCase().equals("assistant"))
else if(des.toLowerCase().equals("manager"))
Pro_manager.search(m, key);
else {
System.out.println("===========================================================
========================================");
break;
int temp=sc.nextInt();
default://default
}while(true);
//********************************************************************//
/*
## Output ##
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::1
=================================================================================
1. INPUT
2. DISPLAY
Choice::1
=================================================================================
Employee ID: 1
=================================================================================
1. PATENT
3.NO
Choice::1
1. PATENT
2. OTHER BENIFICIAL WORK
3.NO
Choice::3
=================================================================================
Employee ID: 45
TRY AGAIN.....
=================================================================================
1. PATENT
3.NO
Choice::3
=================================================================================
Employee ID: 45
=================================================================================
1. PATENT
3.NO
Choice::3
=================================================================================
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::2
=================================================================================
****************************************************************
****************************************************************
****************************************************************
HRA : 3524.1000000000004
PF : 4228.92
****************************************************************
****************************************************************
****************************************************************
****************************************************************
HRA : 3658.9
PF : 4390.68
****************************************************************
****************************************************************
****************************************************************
HRA : 3500.0
PF : 4200.0
****************************************************************
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::3
=================================================================================
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::2
=================================================================================
1. INPUT
2. DISPLAY
Choice::1
==================================================================================
=================
Employee ID: 42
=================================================================================
1. PATENT
3.NO
Choice::1
1. PATENT
3.NO
Choice::2
1. PATENT
3.NO
Choice::3
=================================================================================
Enter the name of Employee: Harsh
Employee ID: 36
TRY AGAIN.....
=================================================================================
1. PATENT
3.NO
Choice::3
=================================================================================
Employee ID: 56
=================================================================================
1. PATENT
3.NO
Choice::3
=================================================================================
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::2
==================================================================================
=================
****************************************************************
****************************************************************
****************************************************************
HRA : 4523.6
PF : 5428.32
****************************************************************
****************************************************************
****************************************************************
****************************************************************
HRA : 4526.3
PF : 5431.5599999999995
****************************************************************
****************************************************************
****************************************************************
HRA : 4526.0
PF : 5431.2
****************************************************************
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::3
==================================================================================
=================
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::3
=================================================================================
ASSISTANT MANAGER MENU .....
1. INPUT
2. DISPLAY
Choice::1
==================================================================================
=================
Employee ID: 47
=================================================================================
1. PATENT
3.NO
Choice::1
1. PATENT
3.NO
Choice::2
1. PATENT
3.NO
Choice::3
=================================================================================
Employee ID: 32
Enter Address: Jalgaon
TRY AGAIN.....
=================================================================================
1. PATENT
3.NO
Choice::3
=================================================================================
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::2
==================================================================================
=================
****************************************************************
****************************************************************
****************************************************************
HRA : 5742.1
PF : 6890.5199999999995
****************************************************************
****************************************************************
****************************************************************
****************************************************************
HRA : 5638.200000000001
PF : 6765.84
****************************************************************
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::3
==================================================================================
=================
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::4
=================================================================================
1. INPUT
2. DISPLAY
Choice::1
==================================================================================
=================
Employee ID: 53
=================================================================================
1. PATENT
3.NO
Choice::1
1. PATENT
3.NO
Choice::2
1. PATENT
3.NO
Choice::3
=================================================================================
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::2
==================================================================================
=================
****************************************************************
****************************************************************
****************************************************************
HRA : 6853.200000000001
PF : 8223.84
****************************************************************
==================================================================================
=================
1. INPUT
2. DISPLAY
Choice::3
==================================================================================
=================
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::5
=================================================================================
EMPLOYEE FOUND
****************************************************************
****************************************************************
****************************************************************
HRA : 3524.1000000000004
PF : 4228.92
****************************************************************
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::5
=================================================================================
EMPLOYEE FOUND
****************************************************************
****************************************************************
****************************************************************
HRA : 6853.200000000001
PF : 8223.84
****************************************************************
==================================================================================
=================
=================================================================================
MAIN MENU
1.PROGRAMMER
2.TEAM LEAD
4.PROJECT MANAGER
5.EMPLOYEE SEARCH
6.EXIT
Choice::6
=================================================================================
1.YES
2.No
Choice::1
*/