DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING
Experiment 1.1
Student Name: Saikumar Swarnapudi UID: 22BCS12422
Branch: CSE Section: 616-A
Semester: 6th Date of performance:08/01/25
Subject: Project based learning in Java Subject Code:22CSH-359
Aim: Create an application to save employee information using arrays.
Objective: To develop a functional application that effectively utilizes arrays to
store, manage, and retrieve employee information, enabling efficient data
organization and manipulation within the application.
Algorithm:
Step 1: Initialize the Program
Start the program.
Define an array of structures to store employee information.
Each structure will include fields such as Employee ID, Name, Age, and Department.
Step 2: Define Functions
1. Add Employee Information:
o Prompt the user to enter details for an employee (ID, Name, Age, Department).
o Store the entered details in the next available position in the array.
o Check for array overflow (i.e., maximum number of employees).
2. Display All Employee Information:
o Iterate through the array and print all stored employee details.
o Handle cases where no employees are stored.
3. Search for an Employee:
o Prompt the user to enter the Employee ID.
o Search the array for a matching ID.
o Display the employee's details if found, otherwise print a message indicating the
ID is not found.
4. Exit Application:
o Provide an option to exit the program.
Step 3: Display Menu
Display a menu with options to:
1. Add Employee
2. View All Employees
3. Search for an Employee
4. Exit
DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING
Step 4: Handle User Input
Use a loop to repeatedly display the menu and prompt the user for a choice.
Call the appropriate function based on the user's selection.
Ensure input validation for numeric values and string lengths.
Step 5: Terminate Program
Exit the loop when the user selects the Exit option.
Code:
import [Link];
import [Link];
class Employee
{ private String
name; private int
empNo;
private char desigCode;
private String dept;
private int basic;
private int hra;
private int it;
public Employee(String name, int empNo, char desigCode, String dept, int basic, int hra, int
it) {
[Link] = name;
[Link] = empNo;
[Link] = desigCode;
[Link] = dept;
[Link] = basic;
[Link] = hra;
[Link] = it;
}
public int getEmpNo()
{ return [Link];
}
public char getDesigCode()
{ return [Link];
}
public String getDept()
{ return [Link];
}
public String getName()
{ return [Link];
}
DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING
public int calculateGrossSalary()
{ return [Link] + [Link];
}
public int getIt()
{ return [Link];
}
}
class Department
{ private char
desigCode;
private String designation;
private int da;
public Department(char desigCode, String designation, int da)
{ [Link] = desigCode;
[Link] = designation;
[Link] = da;
}
public char getDesigCode()
{ return [Link];
}
public String getDesignation()
{ return [Link];
}
public int getDa()
{ return [Link];
}
}
class FindEmployee {
public Employee getEmpById(int id, ArrayList<Employee> employees)
{ for (Employee emp : employees) {
if ([Link]() == id)
{ return emp;
}
}
return null;
}
public void printSalary(Employee emp, ArrayList<Department> departments)
{ char desigCode = [Link]();
int grossSalary = [Link]();
int it = [Link]();
for (Department dept : departments) {
if ([Link]() == desigCode) {
DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING
int salary = grossSalary + [Link]() - it;
[Link]("%d %s %s %s %d\n",
[Link](),
[Link](),
[Link](),
[Link](),
salary);
return;
}
}
}
}
public class Project1 {
public static void main(String[] args)
{ ArrayList<Employee> employees = new ArrayList<>();
[Link](new Employee("Ashish", 1001, 'e', "R&D", 20000, 8000, 3000));
[Link](new Employee("Sushma", 1002, 'c', "PM", 30000, 12000, 9000));
[Link](new Employee("Rahul", 1003, 'k', "Acct", 10000, 8000, 1000));
[Link](new Employee("Chahat", 1004, 'r', "Front Desk", 12000, 6000, 2000));
[Link](new Employee("Ranjan", 1005, 'm', "Engg", 50000, 20000, 20000));
[Link](new Employee("Suman", 1006, 'e', "Manufacturing", 23000, 9000, 4400));
[Link](new Employee("Tanmay", 1007, 'c', "PM", 29000, 12000, 10000));
ArrayList<Department> departments = new ArrayList<>();
[Link](new Department('e', "Engineer", 20000));
[Link](new Department('c', "Consultant", 32000));
[Link](new Department('k', "Clerk", 12000));
[Link](new Department('r', "Receptionist", 15000));
[Link](new Department('m', "Manager", 40000));
Scanner scanner = new Scanner([Link]);
[Link]("Enter the employee ID:");
int empId = [Link]();
FindEmployee finder = new FindEmployee();
Employee foundEmp = [Link](empId, employees);
if (foundEmp != null) {
[Link]("Emp No. Emp Name Department Designation Salary");
[Link](foundEmp, departments);
} else {
[Link]("There is no employee with empid: %d\n", empId);
}
[Link]();
}
}
DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING
Output:
Learning Outcomes:
1. Demonstrate: Apply key concepts to real-world scenarios to showcase understanding.
2. Analyze: Critically evaluate information, identify patterns, and draw
meaningful conclusions.
3. Create: Develop original work, including presentations, reports, or projects, to
exhibit comprehension and skills.
4. Communicate: Convey ideas and findings effectively through oral and
written communication.
5. Collaborate: Contribute to group projects and exhibit strong teamwork capabilities in
a collaborative environment.
DEPARTMENT OF
COMPUTERSCIENCE &ENGINEERING