commit e7c64ae1c92b3c8c833c8ff118aef996c3f70890 Author: Manoj HV Date: Wed Dec 17 15:31:20 2025 +0530 first code diff --git a/Employee.class b/Employee.class new file mode 100644 index 0000000..9bb7185 Binary files /dev/null and b/Employee.class differ diff --git a/EmployeeDatabase.class b/EmployeeDatabase.class new file mode 100644 index 0000000..04e198b Binary files /dev/null and b/EmployeeDatabase.class differ diff --git a/EmployeeDatabase.java b/EmployeeDatabase.java new file mode 100644 index 0000000..03b032c --- /dev/null +++ b/EmployeeDatabase.java @@ -0,0 +1,109 @@ +import java.util.Scanner; + +class Employee { + + String name; + int empId; + String department; + int age; + String designation; + double salary; + + // Method to read employee details + void readEmployee(Scanner sc) { + System.out.print("Enter Name: "); + name = sc.nextLine(); + + System.out.print("Enter Employee ID: "); + empId = sc.nextInt(); + sc.nextLine(); // consume newline + + System.out.print("Enter Department: "); + department = sc.nextLine(); + + System.out.print("Enter Age: "); + age = sc.nextInt(); + sc.nextLine(); + + System.out.print("Enter Designation: "); + designation = sc.nextLine(); + + System.out.print("Enter Salary: "); + salary = sc.nextDouble(); + sc.nextLine(); + + System.out.println("---------------------------------"); + } + + // Method to display employee details + void displayEmployee() { + System.out.println("Name: " + name); + System.out.println("Employee ID: " + empId); + System.out.println("Department: " + department); + System.out.println("Age: " + age); + System.out.println("Designation: " + designation); + System.out.println("Salary: " + salary); + System.out.println("---------------------------------"); + } +} + +public class EmployeeDatabase { + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + int n = 5; // minimum 5 employees + Employee[] emp = new Employee[n]; + + // Read employee details + for (int i = 0; i < n; i++) { + System.out.println("\nEnter details of Employee " + (i + 1)); + emp[i] = new Employee(); + emp[i].readEmployee(sc); + } + + // Display all employee details + System.out.println("\n===== Employee Details ====="); + for (int i = 0; i < n; i++) { + emp[i].displayEmployee(); + } + + // Calculate total salary of Sales department + double salesTotal = 0; + for (int i = 0; i < n; i++) { + if (emp[i].department.equalsIgnoreCase("Sales")) { + salesTotal += emp[i].salary; + } + } + System.out.println("Total Salary of Sales Department: " + salesTotal); + + // Find highest paid Manager in Purchase department + Employee highestPaidManager = null; + + for (int i = 0; i < n; i++) { + if ( + emp[i].department.equalsIgnoreCase("Purchase") && + emp[i].designation.equalsIgnoreCase("Manager") + ) { + if ( + highestPaidManager == null || + emp[i].salary > highestPaidManager.salary + ) { + highestPaidManager = emp[i]; + } + } + } + + // Display result + if (highestPaidManager != null) { + System.out.println( + "\n===== Highest Paid Manager in Purchase Department =====" + ); + highestPaidManager.displayEmployee(); + } else { + System.out.println("\nNo Manager found in Purchase Department."); + } + + sc.close(); + } +}