-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathEmployeePerson.java
More file actions
36 lines (35 loc) · 1003 Bytes
/
EmployeePerson.java
File metadata and controls
36 lines (35 loc) · 1003 Bytes
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
package kethua;
import java.util.Scanner;
class Person {
protected String name;
protected int age;
Person (String ten, int tuoi) {
this.name = ten;
this.age = tuoi;
}
void perDisplay () {
System.out.println ("Ten = " + name);
System.out.println ("Tuoi = " + age);
}
}
class Employee extends Person {
double salary;
Employee (String ten, int tuoi, double luong) {
super(ten, tuoi);
this.salary = luong;
}
}
public class EmployeePerson {
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
System.out.print("Nhap ten: ");
String t = sc.nextLine();
System.out.print("Nhap tuoi: ");
int x = sc.nextInt();
System.out.print("Nhap luong: ");
double y = sc.nextDouble();
Employee e = new Employee(t, x, y);
e.perDisplay();
System.out.println("Luong = " + e.salary);
}
}