0% found this document useful (0 votes)
96 views

Java

The document contains the code for a Java program that stores employee data like ID, name, department, designation and salary in arrays. It takes an employee ID as input, searches for it in the employee ID array and if found, prints the employee details like name, department, designation and salary calculated based on the designation code. If the ID is invalid, it prints an error message.

Uploaded by

Debasis Dutta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views

Java

The document contains the code for a Java program that stores employee data like ID, name, department, designation and salary in arrays. It takes an employee ID as input, searches for it in the employee ID array and if found, prints the employee details like name, department, designation and salary calculated based on the designation code. If the ID is invalid, it prints an error message.

Uploaded by

Debasis Dutta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

public class Project1 {

public static void main(String args[])


{
int[] empid=new int[] {1001,1002,1003,1004,1005,1006,1007};
String[] empname=new String[]
{"Ashish","Sushma","Rahul","Chahat","Ranjan","Suman","Tanmay"};
String[] joindate=new String[]
{"01/04/1999","23/08/2012","12/11/2008","29/01/2013","16/07/2005","01/01/2000","
12/06/2006"};
char[] desigcode=new char[]{'e','c','k','r','m','e','c'};
String[] dept=new String[]{"R&D","PM","Accounts","Front
Desk","Engineering","Manufacturing","PM"};
int[] basic=new int[]{20000,30000,10000,12000,50000,23000,29000};
int[] hra=new int[]{8000,12000,8000,6000,20000,9000,12000};
int[] it=new int[]{3000,9000,1000,20000,4400,10000};
int empno=Integer.parseInt(args[0]);
int a=-1;
for(int i=0;i<empid.length;i++)
{
if(empno==empid[i])
{
a=i;
break;
}
}
if(a!=-1)
{
String Name=empname[a];
String Dept=dept[a];
String desig=null;
int salary=basic[a]+hra[a]-it[a];
switch(desigcode[a])
{
case 'e':
desig="Engineering";
salary=salary+20000;
break;
case 'c':
desig="Consultancy";
salary=salary+32000;
break;
case 'k':
desig="clerk";
salary=salary+12000;
break;
case 'r':
desig="Receptionist";
salary=salary+15000;
break;
case 'm':
desig="Manager";
salary=salary+40000;
break;
}
System.out.println("empno \t Name \t Department \t Designation \t
Salary");
System.out.println(empid[a]+" "+empname[a]+" "+dept[a]+" "+desig+"
"+salary);
}
else
{
System.out.println("invalid empid");

This study source was downloaded by 100000834089164 from CourseHero.com on 05-14-2022 21:50:52 GMT -05:00

https://www.coursehero.com/file/14914383/Employee-Detailsjava/
}
}
}

This study source was downloaded by 100000834089164 from CourseHero.com on 05-14-2022 21:50:52 GMT -05:00

https://www.coursehero.com/file/14914383/Employee-Detailsjava/
Powered by TCPDF (www.tcpdf.org)

You might also like