Rahul-JAVA Exp 1
Rahul-JAVA Exp 1
1. Aim:
Create an application to save the employee information using arrays in Java.
2. Objective:
• Implement an array to store employee information such as Employee ID, Name,
Designation, and Salary.
• Perform Create, Read, Update, and Delete operations on the employee data stored in
the array.
• Develop methods to access specific employee records and modify or delete them
based on user input.
• Display the stored employee data in a structured format to verify the correctness
of the operations.
3. Implementation/Code:
import java.util.Scanner;
class Employee {
String name;
int id;
String department;
Employee(String name, int id, String department) {
this.name = name;
this.id = id;
this.department = department;
}
}
public class EmployeeApp {
public static void main(String[] args) {
DEPARTMENT OF
COMPUTER SCIENCE &
ENGINEERING
Scanner scanner = new Scanner(System.in);
Employee[] employees = new Employee[5];
int count = 0;
while (count < 5) {
System.out.print("Enter employee name: ");
String name = scanner.nextLine();
System.out.print("Enter employee ID: ");
int id = scanner.nextInt();
scanner.nextLine();
System.out.print("Enter employee department: ");
String department = scanner.nextLine();
employees[count] = new Employee(name, id, department);
count++;
System.out.println("Do you want to enter more employees? (y/n)");
String choice = scanner.nextLine();
if (choice.equalsIgnoreCase("n")) {
break;
}
}
System.out.println("Employee Information:");
for (int i = 0; i < count; i++) {
System.out.println("Name: " + employees[i].name + ", ID: " + employees[i].id + ",
Department: " + employees[i].department);
}
}
}
4. Output:
DEPARTMENT OF
COMPUTER SCIENCE &
ENGINEERING
5. Learning Outcome