Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Java to realize simple employee Management system

Shulou Source: shulou.com Published: 2022-06-01 12:16:29 09月30日 Update

This article mainly explains "how to use Java to achieve a simple employee management system", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use Java to achieve a simple employee management system"!

The code is as follows:

Import java.util.*;public class Demo {public static void main (String [] args) {EmpManage em = new EmpManage (); while (true) {System.out.println ("= employee management system ="); System.out.println ("= 0. Load original information = "); System.out.println (" = 1. Join the employee = "); System.out.println (" = 2. Delete employee = "); System.out.println (" = 3. Query employee information = "); System.out.println (" = 4. Modify employee salary = "); System.out.println (" = 5. Salary order = = "); System.out.println (" = 6. Average wage, minimum and maximum wage = "); System.out.println (" = 7. Print all employee information = "); System.out.println (" = 8. Exit the system = "); System.out.print (" Please select function [0x8]: "); Scanner reader = new Scanner (System.in); int x; x = reader.nextInt (); switch (x) {case 0: Employee E1 = new Employee (" 2001 "," Xuanyuan GE ", 2002f) Employee f = new Employee ("2002", "seasonal long wind", 4500f); Employee g = new Employee ("2003", "young fish", 2560f); Employee h = new Employee ("2004", "Bruce Lee", 1604f); em.addEmp (E1); em.addEmp (f); em.addEmp (g) Em.addEmp (h); System.out.println ("loaded!") ; break; case 1: System.out.println ("Please enter information about the employee to be added (number, name, salary separated by a space)"; String a, b; float c; a = reader.next (); b = reader.next () C = reader.nextFloat (); Employee e = new Employee (a, b, c); em.addEmp (e); System.out.println ("join successfully!") ; break; case 2: System.out.print ("Please enter the number of the employee to be deleted:"); String y; y=reader.next (); em.deleteEmp (y); System.out.println ("deleted successfully!") ; break; case 3: System.out.print ("Please enter the number of staff to be queried:"); String z; z=reader.next (); em.showinfo (z); break Case 4: System.out.print ("Please enter the number of staff to be modified:"); String w; w=reader.next (); System.out.print ("Please enter the number of wages to be modified:"); float v; v=reader.nextFloat () Em.changesal (w, v); System.out.println ("modified successfully!") ; break; case 5: System.out.println ("1. Sort by salary order from highest to lowest "); System.out.println (" 2. Sort by salary from low to high "); System.out.print (" Please select the function [1: 2]: "); int t; t=reader.nextInt (); if (tweeted 1) {em.sorthl () } if (tweezers 2) {em.sortlh ();} break; case 6: em.hlsal (); break; case 7: em.showAll (); break Case 8: System.out.println ("the program is finished, see you next time!") ; System.exit (0); break; default: System.out.print ("numbers can only range from 1 to 8!") ;} / / employee management class class EmpManage {private ArrayList al=null; / / Constructor public EmpManage () {al=new ArrayList ();} / join employee method public void addEmp (Employee e) {al.add (e);} / delete employee public void deleteEmp (String x) {int i; for (item0) I

Tags: Employee salary Information salary sorting system Management Management system success input method minimum maximum name Learning content function order query run Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Linux Docker NVidia Xiaomi