-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUap.java
87 lines (86 loc) · 3.52 KB
/
Uap.java
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.Scanner;
import javax.swing.JOptionPane;
public class Uap {
public static void main(String[] args) {
UapCse myUap = new UapCse("CSE");
Scanner scan = new Scanner(System.in);
UI choice = new UI();
while(true){
choice.option();
int op = scan.nextInt();
if(op==1){
while(true){
choice.subEmployeeOption();
int subOp = scan.nextInt();
if(subOp==1){
System.out.println("Enter new Employee's Name,Id,Designation & Salary respectively: ");
scan.nextLine();
String n = scan.nextLine();
String i = scan.nextLine();
String d = scan.nextLine();
double s = scan.nextDouble();
myUap.addNewEmployee(n,i,d,s);
break;
}
else if(subOp==2){
System.out.println("Enter new Employee's Name,Id,Designation,Hourly Rate & Hourly Work respectively: ");
scan.nextLine();
String n = scan.nextLine();
String i = scan.nextLine();
String d = scan.nextLine();
double hr = scan.nextDouble();
int hw = scan.nextInt();
myUap.addNewEmployee(n,i,d,hr,hw);
break;
}
else if(subOp==3){
System.out.println("Enter new Employee's Name,Id,Designation,Commission & Sale respectively: ");
scan.nextLine();
String n = scan.nextLine();
String i = scan.nextLine();
String d = scan.nextLine();
double c = scan.nextDouble();
double s = scan.nextDouble();
myUap.addNewEmployee(n,i,d,c,s);
break;
}
else
System.out.println("Wrong key pressed! Please try again.");
}
}
else if(op==2){
System.out.println("Enter employee's ID: ");
String i = scan.next();
double s = myUap.getSalary(i);
if(s!=-1)
System.out.println(s);
}
else if(op==3){
System.out.println("Enter employee's ID & the amount need to be raised: ");
String i = scan.next();
double d = scan.nextDouble();
try{
myUap.increaseSalary(i, d);
}
catch(InvalidSalaryException e){
JOptionPane.showMessageDialog(null,e.getMessage());
// System.out.println(e.getMessage());
// e.printStackTrace();
}
}
else if(op==4){
System.out.println("Enter employee's ID: ");
String i = scan.next();
myUap.display(i);
}
else if(op==5){
myUap.display();
}
else if(op==0){
break;
}
else
System.out.println("Wrong key pressed! Please try again.");
}
}
}