forked from cs-dept-ibbul/java2019
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab6TestEmployee2.java
More file actions
39 lines (39 loc) · 1.48 KB
/
Copy pathLab6TestEmployee2.java
File metadata and controls
39 lines (39 loc) · 1.48 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
/**
* Write a description of class TestEmployee2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class TestEmployee2
{
public static void main(String[ ] args) {
Scanner input = new Scanner(System. in);
int number;
String name;
double salary;
System.out.print("Enter Name for Employee 1: ");
name = input.nextLine();
System.out.print("Enter ID Number for Employee 1: ");
number = input.nextInt();
System.out.print("Enter Salary for Employee 1: ");
salary = input.nextDouble();
//any of the following constructors be used to create the object
Employee2 emp1 = new Employee2(number, name, salary);
// or Employee1 emp1 = new Employee1(name, number, salary) ;
input.nextLine();
System.out.print("\nEnter Name for Employee 2: ");
name = input.nextLine();
//input.nextLine();
System.out.print("Enter ID Number for Employee 2: ");
number = input.nextInt();
//if we do not know the salary, we can use one of the following constructors
Employee2 emp2 = new Employee2(number, name);
//or Employee1 emp2 = new Employee1(name, number) ;
emp2.setSalary(emp1.getSalary());
emp1.deductions(50);
emp2.deductions(60, 40);
emp1.printDetails();
emp2.printDetails();
}
}