Day 10: Simple Employee Management System

Posted by simanta on Sat, 31 Aug 2019 06:35:08 +0200

Requirement:
Complete the Employee Management System Project.
Function List: 1. Employee Enrollment
2. Show a list of all employees
3. Employee Queries
4. Employee turnover
Among them, the work and vip service requirements of the three personnel are as follows:
Employee Type Job vip Service
Headmaster is responsible for class management and for class management
Teachers are responsible for class management, after-class coaching and job inspection
Manager is responsible for the management of the whole department.

3. Database Design
None.

4. Specific requirements and recommended implementation steps
1. System Start Menu

1.1 When the user chooses menu 1, he or she needs to enter the employee's information. After entering an employee's information, he or she asks if he or she wants to continue adding the employee.

1.2 Menu 2 shows a list of all employees

3.3 Query employees, display employee information when queried, and display the hint of "no query results" if not queried:

5.4 Deleting an employee requires entering a work number
Delete the employee if the input is correct and exclude the deleted employee when the employee list is displayed again

Input error prompts "Work number input error, deletion failure"

5.5, Exit the system, the system ended normally

import java.util.Scanner;

/**
 * 
 * Employee Management System
 * @author 11142
 *
 */
public class StaffMsg {
	public static void main(String[] args) {
		String[] staffTypes = {"Headmaster","Teacher","manager"};
		String[] works = {"Responsible for class management","Responsible for daily teaching","Responsible for the management of the whole department"};
		String[] vips = {"Student Interview, Student Home Visit","After-school tutoring, job checking","nothing"}; 
		
		String[] names = new String[10];
		String[] ids = new String[10];
		int[] chooses = new int[10];
		double[] moneys = new double[10];
		
		names[0] = "calmly";
		ids[0] = "0001";
		chooses[0] = 1;
		
		names[1] = "to one's heart's content";
		ids[1] = "0002";
		chooses[1] = 2;
		
		names[2] = "Feminine";
		ids[2] = "0003";
		chooses[2] = 3;
		moneys[2] = 5000;
 		
		
		
		int index = -1;
		Scanner sc = new Scanner(System.in);
		int num = -1;
		boolean isExit = false;
		do {
			System.out.println("\n***********Employee Management System*************");
			System.out.println("***********[1]Employee Enrollment**************");
			System.out.println("***********[2]Employee List**************");
			System.out.println("***********[3]Query Employees**************");
			System.out.println("***********[4]Employee turnover**************");
			System.out.println("***********[0]Exit System**************");
			String name = "";
			String id = "";
			int chooseType = -1;
			String goOn = "";
			double money = 0;
			boolean flag = false;
			boolean isAdd = false;
			
			System.out.print("Please enter the function number:");
			int choose = sc.nextInt();
			switch (choose) {
			case 1:
				//[1] Employee Enrollment
				do {
					for (int j = 0; j < names.length; j++) {
						if (null == names[j]) {
							System.out.print("Employee ID:");
							id = sc.next();
							System.out.print("Please enter employee name:");
							name = sc.next();
							System.out.print("Select employee type(1: Head 2: Teacher 3: Department Manager): ");
							chooseType = sc.nextInt();
							if (chooseType == 3) {
								System.out.print("Please enter the manager's bonus amount:");
								money = sc.nextDouble();
							}
							for (int i = 0; i < names.length; i++) {
								if (null != names[i] && id.equals(ids[i])) {
									flag = true;
									System.out.println("Same work number, add failed!");
									break;
								}
							}
							if (!flag) {
								names[j] = name;
								ids[j] = id;
								chooses[j] = chooseType;
								moneys[j] = money;
								System.out.println("Add employee complete!");
							}
							break;
						}
					}
					System.out.print("Do you want to continue adding(y Continue,Any key return): ");
					goOn = sc.next();
				} while (goOn.equals("y"));

				break;
			case 2:
				//[2] Employee List
				for(int i=0; i<names.length; i++) {
					if(names[i] != null) {
						System.out.println("Position:" + staffTypes[chooses[i]-1]);
						if(chooses[i]==3) {
							System.out.println("The Employee's Employee Number is:" + ids[i] + ",Name:" + names[i] + ",Bonus is:" + moneys[i]);
						}else {
							System.out.println("The Employee's Employee Number is:" + ids[i] + ",Name:" + names[i]);
						}
						System.out.println(works[chooses[i]-1]);
						if(chooses[i]==3) {
							System.out.println("No, VIP Services can be provided");
						}else {
							System.out.println("Available VIP Services:" + vips[chooses[i]-1]);
						}
						System.out.println();
					}
				}
				break;
			case 3:
				//[3] Query employees
				System.out.print("Please enter the name of the employee you want to query(Support for fuzzy queries): ");
				name = sc.next();
				for(int i=0; i<names.length; i++) {
					//Fuzzy Query Using contains Method
					if(names[i] != null && names[i].contains(name)) {
						flag =true;
						System.out.println("Full name:" + names[i]);
						System.out.println("Position:" + staffTypes[chooses[i]-1]);
						if(chooses[i]==3) {
							System.out.println("The Employee's Employee Number is:" + ids[i] + ",Name:" + names[i] + ",Bonus is:" + moneys[i]);
						}else {
							System.out.println("The Employee's Employee Number is:" + ids[i] + ",Name:" + names[i]);
						}
						System.out.println(works[chooses[i]-1]);
						System.out.println();
						break;
					}
				}
				if(!flag) {
					System.out.println("No results found!\n");
				}
				break;
			case 4:
				//[4] Employee turnover
				System.out.print("Please enter the number of the employee who needs to leave:");
				id = sc.next();
				for (int i = 0; i < names.length; i++) {
					if(names != null && id.equals(ids[i])) {
						flag =true;
						names[i] = null;
						ids[i] = null;
						chooses[i] = 0;
						moneys[i] = 0;
						System.out.println("Delete this employee complete!");
						break;
					}
				}
				if(!flag) {
					System.out.println("Work Number Entry Error, Delete Failed!");
				}
				break;
			case 0:
				//[0] Exit the system
				isExit = true;
				break;

			default:
				System.out.println("Your input is incorrect!");
				break;
			}
			if (!isExit){
				do {
					System.out.print("Enter 9 to return to the main menu:");
					num = sc.nextInt();
				} while (num != 9);
			} else {
				break;
			}
		} while (num == 9);
		System.out.println("\n You have successfully exited the system!");
		
	}
}

Topics: Database Java