2.4 Java Akshat
2.4 Java Akshat
Experiment 2.4
Student Name: Akshat Sharma UID: 21BCS10347
Branch: CSE Section/Group: 614-B
Semester: 6th Date: 22/03/2024
Subject Name: PBL in Java with Lab Subject Code: 21CSH-319
1. Aim: Create a menu based Java application with the following options.1. Add
an Employee2.Display All3.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.
3. Objective:
To learn about concept of File Handling in java.
while (n <= 3) {
if (n > 3) {
System.out.println("Wrong input entered!!");
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
break;
switch (n) {
case 1:
System.out.println("Enter Employee ID: ");
int id = sc.nextInt();
sc.nextLine();
System.out.println("Enter Employee Name: ");
String name = sc.nextLine();
System.out.println("Enter Employee Age: ");
int age = sc.nextInt();
System.out.println("Enter Employee Salary: ");
double salary = sc.nextDouble();
ids.add(id);
names.add(name);
ages.add(age);
salaries.add(salary);
System.out.println("Inserted Successfully");
break;
case 2:
System.out.println("----Report ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) +
" " + names.get(i) +
" " + ages.get(i) +
" " + salaries.get(i));
}
System.out.println("----End of Reort ");
break;
case 3:
System.out.println("Exiting the System");
break;
default:
System.out.println("Wrong input entered!!");
break;
}
if (n == 3)
break;
sc.close();
}
}
OUTPUT:
Learning Outcomes:
Learnt about various functions
Learnt about ArrayList
Learnt about how to add details
Learnt about how to access the elements.