Experiment 1
Student Name: Gaurav UID: 20BCS6806
Branch: AIML Section/Group: 20AIML5-B
Semester: 4th Date of Performance:18/02/22
Subject Name: PROJECT-BASED LEARNING Subject Code: 20CSP-287
IN JAVA LAB
1. Aim/Overview of the practical
Create an application to save the employee information using arrays having following fields
empid[], depName[], empDes, empName[], dateJoin[], basic[], hra[], it[], DesCodes[].
2. Task:
(a) Salary should be calculated as (Basic+HRA+DA-IT)
(b)Printing designation and da according to employee designation.
3. Code:
package com.gaurav;
import java.util.Arrays;
import java.util.Scanner;
public class blackboard {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int f = 0, index = -1, Dearence_Allowance = 0, salary;
char empDes;
int[] emp_id = new int[]{6801, 6802, 6803, 6804, 6805, 6806, 6807};
String[] Department_Name = new String[]{"R&D", "PM", "Acct", "Front Desk",
"Website Handling", "Manufacturing", "Technical Support"};
String[] Employee_Name = new String[]{"Gaurav", "Atul", "Yogesh", "Yash", "Guru",
"Bhuvan", "Tim"};
String[] dateJoin = new String[]{"1/04/2002", "23/08/2013", "12/11/2018",
"29/01/2011", "16/07/2015", "1/01/2006", "12//06/2003"};
int[] basic = new int[]{60000, 20000, 20000, 32000, 40000, 21000, 25000};
int[] House_rent_allowance = new int[]{18000, 10000, 6000, 8000, 23000, 1200,
13000};
int[] it = new int[]{13000, 6000, 2000, 3000, 10000, 8400, 12000};
String Designation = null;
char[] DesCodes = new char[]{'e', 'c', 'k', 'r', 'm', 'e', 'c'};
System.out.println("Enter Employee ID");
int id = sc.nextInt();
for (int i = 0; i < (emp_id.length); i++) {
if (id == emp_id[i]) {
index = i;
}
}
if (index == -1) {
System.out.println("Emp id does not exist");
return;
}
empDes = DesCodes[index];
switch (empDes) {
case 'e' -> {
Designation = "Engineer";
Dearence_Allowance = 20000;
}
case 'c' -> {
Designation = "Consultants";
Dearence_Allowance = 32000;
}
case 'k' -> {
Designation = "Clerk";
Dearence_Allowance = 12000;
}
case 'r' -> {
Designation = "Receptionist";
Dearence_Allowance = 15000;
}
case 'm' -> {
Designation = "Manager";
Dearence_Allowance = 40000;
}
}
salary = basic[index] + House_rent_allowance[index] + it[index] +
Dearence_Allowance;
System.out.println("Emp no\t\tEmployee
Name\t\tDeaprtment\t\t\tDesignation\t\tSalary\t\tJoining Date");
System.out.println(emp_id[index] + "\t\t\t" + Employee_Name[index] + "\t\t\t" +
Department_Name[index] + " " +
"\t\t\t" + Designation + "\t\t" + salary + "\t\t" + dateJoin[index]);
}
}
4. Output:
Evaluation Grid (To be created as per the SOP and Assessment guidelines by the faculty):
Sr. No. Parameters Marks Obtained Maximum Marks
1.
2.
3.