-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateMember.java
More file actions
64 lines (60 loc) · 1.89 KB
/
createMember.java
File metadata and controls
64 lines (60 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Scanner;
class Member
{
String name,address;
int age;
long phone_number;
float salary;
Member(String name, String address, int age, long phone_number, float salary)
{
this.name = name;
this.address = address;
this.age = age;
this.phone_number = phone_number;
this.salary = salary;
}
public void display()
{
System.out.println("Name= "+name+" Address= "+address+" Age= "+age+" Phone number= "+phone_number+" Salary=Rs."+salary);
}
}
class Employee extends Member
{
String specialization;
public Employee(String name, String address, String specialization, int age, long phone_number, float salary)
{
super(name, address, age, phone_number, salary);
this.specialization = specialization;
}
public void display()
{
super.display();
System.out.println("Specialization= "+specialization);
}
}
class Manager extends Member
{
String department;
Manager(String name, String address, String department, int age, long phone_number, float salary)
{
super(name, address, age, phone_number, salary);
this.department = department;
}
public void display()
{
super.display();
System.out.println("Department= "+department);
}
}
class createMember
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter name, address, specialization, age ,phone number and salary of employee");
Employee obj1 = new Employee(sc.next(),sc.next(),sc.next(),sc.nextInt(),sc.nextLong(),sc.nextFloat());
System.out.println("Enter name, address, department, age ,phone number and salary of employee");
Manager obj2 = new Manager(sc.next(),sc.next(),sc.next(),sc.nextInt(),sc.nextLong(),sc.nextFloat());
obj1.display();
obj2.display();
}
}