Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name: Gagandeep Kaur UID: 20BCS8011

Branch: CSE (LEET) Section/group: 19BCS_IS_15_A

Semester: 6th SEM Date of performance: 15-02-2022

Subject: Project based learning in java lab Subject code: CSP-358

Worksheet No .1

Aim: 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
Code:

package project1;
import java.util.Scanner;
public class Array
{
public static void main(String args[])
{
Scanner arr = new Scanner(System.in);
int capacity = 7;

int eno[] = {1001, 1002, 1003, 1004, 1005, 1006, 1007};


String ename[] = {"Ashish", "Sushma", "Rahul", "Chahat", "Ranjan", "Suman", "Tanmay"};
String dpt[] = {"R&D", "PM", "Acct", "Front Desk", "Eng", "Manufacturer", "PM"};
char dcode[] = {'e', 'c', 'k', 'r', 'm', 'e', 'c'};
int basic[] = {20000, 3000, 10000, 12000, 9000, 12000};
int hra[] = {8000, 12000, 80000, 6000, 200000, 9000, 12000};

int it[] = {3000, 9000, 1000, 2000, 20000, 4400, 10000};


System.out.print("Enter the employee ID: ");
int eid = arr.nextInt();
boolean check = false; int x = 0;
for(int i = 0;i<capacity;i++)
{
if(eno[i] == eid)
{
check = true; x = i;
break;
}
}
if(check == false)
{
System.out.print("NO ID found!"+eid+"\tPlease enter correct one ");
}
else
{
System.out.print("Employee No \tEmp Name\tDepartment\tDesignation\tSalary");
System.out.print(eno[x]+ "\t");
System.out.print(ename[x]+ "\t\t");
System.out.print(dpt[x]+ "\t\t"); System.out.print(dcode(dcode[x])+ "\t\t");
int Salary = basic[x] + hra[x] + da(dcode[x]) - it[x];
System.out.print(Salary);
}
}
static String dcode(char ch)
{
switch(ch)
{
case 'e': return "Engineer"; case 'c': return "Consultant";
case 'k': return "Clerk";
case 'r': return "Receptionist";
case 'm': return "Manager";
}
return "Invalid";
}
static int da(char ch)
{
switch(ch)
{
case 'e': return 20000;
case 'c': return 32000;
case 'k': return 12000;
case 'r': return 15000;
case 'm': return 40000;
}
return 0;
}
}

Output:

You might also like