DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Experiment Title – 2.4
Student Name: Ganesh kumr UID: 20BCS5193
Branch: BE-CSE Section/Group: 20BCS_WM_607_A
Subject Name: PBLJ LAB Subject Code: 21 CSP-321
1. Aim/Overview of the practical: Employee Management System Create
a menu based Java application with the following options.
1. Add an Employee
2. Display All
3. Exit
If option 1 is selected, the application should gather details of the employee like
employee name, employee id, designation and salary and store it in a file.
If option 2 is selected, the application should display all the employee details.
If option 3 is selected the application should exit.
2. Software/Hardware Requirements: IntelliJ
3. Algorithm/pseudo code:
Step1: Start execution.
Step2: Declare 4 ArrayList to store employee name, empoyee id, designation and
salary.
Step3: Using the constructor add values to the arraylist.
Step4: Make a display function to Display the contents of each arraylist using a for
loop.
Step5: In main function take choices as input inside a switch statement.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
Step6: Call the relevant functions as per the entered choices.
Step7: Stop execution.
4. Steps for experiment/practical/Code:
package com.chirag;
import java.util.*; public
class Exp24
static ArrayList<String> empName = new ArrayList<>();
static ArrayList<String> eid = new ArrayList<>(); static
ArrayList<String> designation = new ArrayList<>(); static
ArrayList<Integer> salary = new ArrayList<>(); public
static class Employee{
public void addData(String name1, String eid1, String designation1, int
salary1){
empName.add(name1);
eid.add(eid1);
designation.add(designation1);
salary.add(salary1);
public void display(){
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
for (int i = 0; i < empName.size(); i++){
System.out.println("Name: " + empName.get(i));
System.out.println("Employee ID : " + eid.get(i));
System.out.println("Designation: " + designation.get(i));
System.out.println("Salary: " + salary.get(i));
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(true){
System.out.println("Enter Choices: ");
System.out.println("1. Add Employee");
System.out.println("2. Display");
System.out.println("3. Exit");
int choices = in.nextInt();
Employee emp = new Employee();
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
switch(choices){
case 1:
System.out.println("Enter your Name: ");
String name = in.next();
System.out.println("Enter your Designation: ");
String designation = in.next();
System.out.println("Enter your Eid: ");
String eid = in.next();
System.out.println("Enter your Salary: ");
int salary = in.nextInt();
emp.addData(name, eid, designation,
salary); continue; case 2:
emp.display();
continue; case 3:
return;
}
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
5. Result/Output/Writing Summary:
SCREENSHOT - 1
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
SCREENSHOT - 2
Learning outcomes (What I have learnt):
1. Learned about ArrayList.
2. Learned about Switch Statement
3. Learned about ArrayList Travesal.