Experiment-1
Aim: Create an application to save the employee information using arrays.
Flowchart:
Class Diagram:
Program:
Class Employee:-
package proj;
public class Employee {
private int empNo;
private String empName;
private String joinDate;
private char desigCode;
private String dept;
private int basic;
private int hra;
private int it;
public Employee(int empNo, String empName, String joinDate, char desigCode, String
dept, int basic, int hra,
int it) {
super();
this.empNo = empNo;
this.empName = empName;
this.joinDate = joinDate;
this.desigCode = desigCode;
this.dept = dept;
this.basic = basic;
this.hra = hra;
this.it = it;
}
public int getEmpNo() {
return empNo;
}
public void setEmpNo(int empNo) {
this.empNo = empNo;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public String getJoinDate() {
return joinDate;
}
public void setJoinDate(String joinDate) {
this.joinDate = joinDate;
}
public char getDesigCode() {
return desigCode;
}
public void setDesigCode(char desigCode) {
this.desigCode = desigCode;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public int getBasic() {
return basic;
}
public void setBasic(int basic) {
this.basic = basic;
}
public int getHra() {
return hra;
}
public void setHra(int hra) {
this.hra = hra;
}
public int getIt() {
return it;
}
public void setIt(int it) {
this.it = it;
}
Class Project1:-
package proj;
public class Project1 {
public static void main(String args[]) {
Employee emp[]=new Employee[2];
int empCode;
String designation="";
int da=0;
char descode;
int salary=0;
boolean match=false;
emp[0]=new Employee(1001, "Ashish", "01/04/2009", 'e', "R&D", 20000, 8000, 3000);
emp[1]=new Employee(1002, "Sushma", "23/08/2012", 'c', "PM", 30000, 12000, 9000);
if(args.length<1)
System.out.println("Provide employee code");
else
{
empCode = Integer.parseInt(args[0]);
for(int i=0;i<emp.length;i++)
{
if(empCode==emp[i].getEmpNo())
{
match=true;
descode =emp[i].getDesigCode();
switch(descode)
{
case 'e':
designation="Engineer";
da =20000;
break;
case 'c':
designation="Consultant";
da=32000;
}
salary =emp[i].getBasic()+emp[i].getHra()+da-emp[i].getIt();
System.out.println("Emp
No\tEmpName\tDepartment\tDesignation\tSalary");
System.out.println(emp[i].getEmpNo()+"\t"
+emp[i].getEmpName()+"\t" +emp[i].getDept()+"\t\t" +designation+"\t"+salary);
}
break;
}
if(match==false)
{
System.out.println("There is no employee with empid: "+empCode);
}
}
}
Output: