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

Worksheet 2.4 JAVA

The document describes an experiment to create an employee management system with a menu-driven Java application. The application allows users to add employees by collecting name, ID, designation, and salary into ArrayLists, and displays all employee details stored in the ArrayLists. It provides pseudocode outlining the algorithm and includes the Java code implementing the application with a main menu using a switch statement to call functions for adding or displaying employee data. Screenshots show the application interface and output of an employee added and all employees displayed.

Uploaded by

madhu jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Worksheet 2.4 JAVA

The document describes an experiment to create an employee management system with a menu-driven Java application. The application allows users to add employees by collecting name, ID, designation, and salary into ArrayLists, and displays all employee details stored in the ArrayLists. It provides pseudocode outlining the algorithm and includes the Java code implementing the application with a main menu using a switch statement to call functions for adding or displaying employee data. Screenshots show the application interface and output of an employee added and all employees displayed.

Uploaded by

madhu jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy