Simple CRM Employee Management system

Source: Internet
Author: User

Using the previous study, the use of object-oriented and collection to make a simple CRM operating system.

Create a new employee's Information entry class:

Public class ygong {private int id;private string name;private double  gongzi;public void setid (int id) {this.id=id;} Public int getid () {return id;} Public void setname (string name) {this.name=name;} Public string getname () {return name;} Public void setgongzi (Double gongzi) {This.gongzi=gongzi;} Public double getgongzi () {Return gongzi;} Public string tostring () {return this.id+ " " +this.name+ " " +this.gongzi;}} Create a new class, write the CRM system of the specific operation method: Public class operation {scanner sc=new scanner (system.in); Ygong p=new ygong (); Arraylist list=new arraylist ();//New Employee Information Method Public void add () {Ygong t=new ygong (); System.out.println ("Please enter employee work number"); T.setid (Sc.nextint ()); System.out.println ("Please enter employee name"); T.setname (Sc.next ()); System.out.println ("Please enter employee's salary"); T.setgongzi (sc.nextdouble); List.add (t); System.out.println ("New Success");} Query an employee method Public void query () {System.out.println ("Enter the worker number for the query:"); Int num=sc.nextint ();int  Index=-1;for (Int i=0;i<list.size (); i++) {ygong s= (Ygong)  list.get (i);   //forced transformation if ( S.getid () ==num) {index=i;}} if (index!=-1) {System.out.println (List.get (index));} ELSE{SYSTEM.OUT.PRINTLN ("no Employee");}} Query all Employee Methods Public void queryall () {for (Int i=0;i<list.size (); i++) {System.out.println (List.get ( i));}} Modify Employee Payroll Method Public void updatemoney () {System.out.println ("Enter the employee number for the query:"); Int num=sc.nextint (); int  index=-1;for (Int i=0;i<list.size (); i++) {ygong s= (Ygong)  list.get (i); if (S.getId () ==num) {index=i;}} if (index!=-1) {System.out.println ("Please enter a newly modified salary");d ouble num2=sc.nextdouble (); Ygong s= (Ygong)  list.get (index); S.setgongzi (num2); List.set (index, s); SYSTEM.OUT.PRINTLN ("modified successfully");} ELSE{SYSTEM.OUT.PRINTLN ("no Employee");}} Delete Employee Information Method Public void delete () {System.out.println ("Enter the worker number for the query:"); Int num=sc.Nextint (); Int index=-1;for (Int i=0;i<list.size (); i++) {ygong s= (Ygong)  list.get (i); if ( S.getid () ==num) {index=i;}} if (index!=-1) {list.remove (index); System.out.println ("delete succeeded");} ELSE{SYSTEM.OUT.PRINTLN ("no Employee");}} Sorting method Public void paixu () {arraylist li=new arraylist (); Li.addall (list);// Use a new list collection to receive the contents of the previous collection for (Int i=0;i<li.size (); i++) {//select sort for (Int j=i+1;j<li.size (); j + +) {Ygong  e= (Ygong)  li.get (i); Ygong s= (Ygong)  li.get (j); if (E.getgongzi () <s.getgongzi ()) {li.set (i, s); Li.set (j, e);}} For (Int i=0;i<li.size (); i++) {System.out.println (Li.get (i));}} Statistical Method Public void tongji () {double max=0;double min=0;double sum=0;for (int i=0;i <list.size (); i++) {ygong s= (Ygong)  list.get (i); if (i==0) {Max=s.getgongzi (); Min=s.getgongzi ();} if (S.getgongzi () >max) {Max=s.getgongzi ();} Else if (S.getgongzi () <min) {Min=s.getgongzi ();} Sum+=s.getgongzi ();} SYSTEM.OUT.PRINTLN ("Employee's maximum wageIs "+max+" the minimum wage is "+min+" the average wage is "+sum/list.size ());}} Finally, Main method: Public class main {public static void main (String[] args)  {  todo auto-generated method stubscanner sc=new scanner (System.in); operation  p=new operation (); System.out.println ("Welcome to Employee management system"); for (;;) {System.out.println ("Please select Action item: 1, add 2, Query 3, query all 4, modify 5, delete" +  "6, sort 7, Count 8, exit"); Int num=sc.nextint (); if (num==1 ) {p.add ();} Else if (num==2) {p.query ();} Else if (num==3) {P.queryall ();} Else if (num==4) {P.updatemoney ();} Else if (num==5) {p.delete ();} Else if (num==6) {P.paixu ();} Else if (num==7) {P.tongji ();} Else{system.out.println ("Good-Bye");}}}


Simple CRM Employee Management system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.