-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGiven the following table containing information about employees of an organization, develop a small java application, which accepts employee id from the command prompt and displays the following details as output:
98 lines (94 loc) · 3.57 KB
/
Given the following table containing information about employees of an organization, develop a small java application, which accepts employee id from the command prompt and displays the following details as output:
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
88
89
90
91
92
93
94
95
96
97
98
package com.w3epic.wiprotraining;
import java.util.*;
public class exp_1 {
public static String[][] ETable=new String[][] {
{"1001","Ashish","01/04/2009","e","R&D","20000","8000","3000"},
{"1002","Sushma","23/08/2012","c","PM","30000","12000", "9000"},
{"1003","Rahul","12/11/2008","k","Acct","10000","8000","1000"},
{"1004","Chahat","29/01/2013","r","FrontDesk", "12000","6000","2000"},
{"1005","Ranjan","16/07/2005","m","Engg","50000","20000","20000"},
{"1006","Suman","1/1/2000","e","Manufacturing","23000","9000","4400"},
{"1007","Tanmay","12/06/2006","c","PM","29000","12000","10000"}
};
public static String[][] DTable=new String[][] {
{"e","Engineer","20000"},
{"c","Consultant","32000"},
{"k","Clerk","12000"},
{"r","Receptionist","15000"},
{"m","Manager","40000"}
};
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.println("Enter Employee ID: ");
String id=scan.nextLine();
boolean t=false;
int t1=0;
for(int i=0;i<7;i++)
{
if(id.equals(ETable[i][0]))
{
t=true;
t1=i;
}
}
if(!t)
{
System.out.println("There is no employee with id "+id);
}
else
{
String code=ETable[t1][3];
String name=ETable[t1][1];
String department=ETable[t1][4];
String no=ETable[t1][0];
int basic,hra,it,da,salary=0;
String deg="";
switch(code)
{
case "e":
basic=Integer.parseInt(ETable[t1][5]);
hra=Integer.parseInt(ETable[t1][6]);
it=Integer.parseInt(ETable[t1][7]);
da=20000;
salary=basic+hra-it+da;
deg="Engineer";
break;
case "c":
basic=Integer.parseInt(ETable[t1][5]);
hra=Integer.parseInt(ETable[t1][6]);
it=Integer.parseInt(ETable[t1][7]);
da=32000;
salary=basic+hra-it+da;
deg="Consultant";
break;
case "k":
basic=Integer.parseInt(ETable[t1][5]);
hra=Integer.parseInt(ETable[t1][6]);
it=Integer.parseInt(ETable[t1][7]);
da=12000;
salary=basic+hra-it+da;
deg="Clerk";
break;
case "r":
basic=Integer.parseInt(ETable[t1][5]);
hra=Integer.parseInt(ETable[t1][6]);
it=Integer.parseInt(ETable[t1][7]);
da=15000;
salary=basic+hra-it+da;
deg="Receptionist";
break;
case "m":
basic=Integer.parseInt(ETable[t1][5]);
hra=Integer.parseInt(ETable[t1][6]);
it=Integer.parseInt(ETable[t1][7]);
da=40000;
salary=basic+hra-it+da;
deg="Manager";
break;
}
System.out.printf("%-10s%-10s%-15s%-15s%-10s\n","EmpNo.","EmpName","Department","Designation","Salary");
System.out.printf("%-10s%-10s%-15s%-15s%-10s",no,name,department,deg,salary);
}
scan.close();
}
}