Skip to content

Commit 28f9c71

Browse files
display employee and manager details
1 parent c545470 commit 28f9c71

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

createMember.java

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import java.util.Scanner;
2+
3+
class Member
4+
{
5+
String name,address;
6+
int age;
7+
long phone_number;
8+
float salary;
9+
10+
Member(String name, String address, int age, long phone_number, float salary)
11+
{
12+
this.name = name;
13+
this.address = address;
14+
this.age = age;
15+
this.phone_number = phone_number;
16+
this.salary = salary;
17+
}
18+
public void display()
19+
{
20+
System.out.println("Name= "+name+" Address= "+address+" Age= "+age+" Phone number= "+phone_number+" Salary=Rs."+salary);
21+
}
22+
}
23+
class Employee extends Member
24+
{
25+
String specialization;
26+
27+
public Employee(String name, String address, String specialization, int age, long phone_number, float salary)
28+
{
29+
super(name, address, age, phone_number, salary);
30+
this.specialization = specialization;
31+
}
32+
public void display()
33+
{
34+
super.display();
35+
System.out.println("Specialization= "+specialization);
36+
}
37+
}
38+
class Manager extends Member
39+
{
40+
String department;
41+
42+
Manager(String name, String address, String department, int age, long phone_number, float salary)
43+
{
44+
super(name, address, age, phone_number, salary);
45+
this.department = department;
46+
}
47+
public void display()
48+
{
49+
super.display();
50+
System.out.println("Department= "+department);
51+
}
52+
}
53+
class createMember
54+
{
55+
public static void main(String[] args) {
56+
Scanner sc=new Scanner(System.in);
57+
System.out.println("Enter name, address, specialization, age ,phone number and salary of employee");
58+
Employee obj1 = new Employee(sc.next(),sc.next(),sc.next(),sc.nextInt(),sc.nextLong(),sc.nextFloat());
59+
System.out.println("Enter name, address, department, age ,phone number and salary of employee");
60+
Manager obj2 = new Manager(sc.next(),sc.next(),sc.next(),sc.nextInt(),sc.nextLong(),sc.nextFloat());
61+
obj1.display();
62+
obj2.display();
63+
}
64+
}

0 commit comments

Comments
 (0)