Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I do not understand question. Would be grateful for assistance Employee empID: S

ID: 3695671 • Letter: I

Question

I do not understand question. Would be grateful for assistance

Employee

empID: String

firstName: String

lastName: String

payRate: Real

+      Employee()

SetEmpID(theID: String)

SetFirstName(fName: String)

SetLastName(lName: String)

SetPayRate(testPay: Real)

ValidString(testString: String, validMin: Integer, validLength: Integer, txtMSG: String):String

ValidPay(pay: Real): Real

+      DisplayEmployee():String

Create an employee class based on this UML class diagram.

The setters should prompt the user for the information to set the value of the instance variables. These are the validation rules:

The ID has to be 4 characters long. If it is invalid the characters XXXX have to replace the invalid ID.

The minimum length for a first or last name is 2 characters and the maximum length is 20 characters. If invalid the first or last name have to be replaced with XXXX.

The pay rate has to be between 0 and 1000000. If invalid the pay rate has to be replaced with 0.

Use the ValidString Function to validate the first name, last name and empID. The invalid message should include which item was incorrect. For example if the first name was incorrect it should display “Invalid first name. Set to XXXX”

The DisplayEmployee getter function should display all of the employee information.

Create a program that uses the Employee class to create an array of employee objects based on the user’s input. It should then display all of the employee data in the array.

Example: Module main()

Declare Integer employeeNo

Display “How many employees do you want to enter?” Input employeeNo

Employee

empID: String

firstName: String

lastName: String

payRate: Real

+      Employee()

SetEmpID(theID: String)

SetFirstName(fName: String)

SetLastName(lName: String)

SetPayRate(testPay: Real)

ValidString(testString: String, validMin: Integer, validLength: Integer, txtMSG: String):String

ValidPay(pay: Real): Real

+      DisplayEmployee():String

Explanation / Answer

class student

{

public static void main(String[] args)

{

String empID,firstName,lastName;

double payRate;

int i;

//creating array objects based on number of employees

Scanner sc=new Scanner(System.in);

System.out.println("Enter how many employees you want want read");

i=sc.nextInt();

Student[i] arr=new Student[i];

public String SetEmpID(String theId)

{

empId=theId;

int l=empId.length();

if(l<=4)

empid="XXXX";

else

{

for(i=0;i<l;i++)

                {

                    char c = empId.charAt(i);

                    if(!((c>='a' && c<='z')||(c>='A' && c<='Z')) && c!=' '&& c>='0' && c<='9'))

                    {

          empid="XXXX";

                   }

                }

}//else

}//method

public String SetFirstName(String fName)

{

firstName=fName;

int l= firstName.length();

if(l<2&&l>20)

firstName ="XXXX";

return firstName;

else

{

for(i=0;i<l;i++)

                {

                    char c = firstName.charAt(i);

                    if(!((c>='a' && c<='z')||(c>='A' && c<='Z')) && c!=' '))

                    {

          empid="XXXX";

                   }

                }

}//else

}//method

public String SetLastName(String lName)

{

lastName=lName;

int l= lastName.length();

if(l<2&&l>20)

lastName ="XXXX";

return lastName;

else

{

for(i=0;i<l;i++)

                {

                    char c = lastName.charAt(i);

                    if(!((c>='a' && c<='z')||(c>='A' && c<='Z')) && c!=' '))

                    {

          empid="XXXX";

                   }

                }

}//else

}//method

public double setPayRate(double pay)

{

payRate=pay;

if(payRate<0&& payRate>1000000)

{

return 0;

}

else

return payRate;

}

Public static void displayEmployee()

{

for(j=0;j<i;j++)

{

System.out.println("Enter Employee Id");

empId=sc.nextLine();

System.out.println("Emp id"+ arr[i].setEmpID(empId));

System.out.println("Enter Employee firstname");

firstName=sc.nextLine();

System.out.println("Emp first name"+ arr[i].setFirstName(firstName));

System.out.println("Enter Employee lastname");

lastName=sc.nextLine();

System.out.println("Emp Lastname"+ arr[i].setLastName(lastName));

System.out.println("Enter Employee pay");

payRate=sc.nextDouble();

System.out.println("Emp payrate"+ arr[i].setPayrate(payRate));

}

}//method

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote