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

Can i get some help with this java assignment Using Arrays, Strings, & Sorti I.

ID: 3689020 • Letter: C

Question

Can i get some help with this java assignment

Using Arrays, Strings, & Sorti I. Define a Java class as described below. All variables should be declared as private and all methods as public. Save the class definition in a file with an appropriate filename. Class Name Personnel Instance Variables: Name - String (in the format lastName, firstName - Example: Carter isa jobTitle - String payRate - double (Fields) Instance Methods A default constructor A constructor that accepts three arguments, one for each of the fields getter methods for each of the class fields. toString0 A method to display the fields of an instance of the class in an easy to read format (preferable on one line). Compile and debug the above code. II. Then, create a class, TestPersonnel, that contains a main) with static methods to test and use the above class. Save the class in a file with an appropriate file name. Declare three initialized arrays, one for the Job Code, and two associated arrays for Job Title and the Pay Rates as follows: Job Code 10 15 20 24 30 Job Title Pay Rate $20.50 Manager Assistant Manager 16.50 Accountant Cashier Stocker 15.50 9.50 7.25

Explanation / Answer

package assignment;

import java.util.ArrayList;
import java.util.Scanner;

public class TestPersonnel {
   public static void main(String[] args) {
      
       int jobCode[] = {10,15,20,24,30};
       String jobTitle[] = {"Manager", "Assistant MAnager"
               ,"Accountant", "Cashier", "Stocker"};
       double payRate[] = {20.50,16.50,15.50,9.50,7.25};
       ArrayList<Personel> personnel = getUserDetails(jobCode, jobTitle, payRate);
      
   }
  
   public static void display(ArrayList<Personel> personnel) {
       for(Personel per: personnel)
           System.out.println(per.toString());
   }
  
   public static ArrayList<Personel> getUserDetails(int jobCode[],String jobTitle[], double payRate[]) {
       ArrayList<Personel> personel = new ArrayList<Personel>();
       Scanner scan = new Scanner(System.in);
       String option = null;
       String fname;
       String lname;
       int jCode;
       Personel per = null;
       boolean cont = true;
       do {
           System.out.println("Enter first name: ");
           fname = scan.nextLine();
           System.out.println("Enter last name: ");
           lname = scan.nextLine();
          
           do {
               System.out.println("Enter job code: ");
               jCode = scan.nextInt();
               for(int i = 0; i < jobCode.length; i++) {
                   if(jobCode[i] == jCode) {
                       cont = false;
                       per = new Personel(fname+", "+lname, jobTitle[i], payRate[i]);
                       personel.add(per);
                       break;
                   }
               }
           } while(cont);
           System.out.println("Do you want enter another entry: (Y/N)");
           option = scan.next();
          
       } while(!"N".equalsIgnoreCase(option.trim()));
      
       return personel;
      
   }
}

class Personel {

   private String name;
   private String jobTitle;
   private double payRate;
  
   public Personel(String name,String jobTitle,double payRate) {
       this.name = name;
       this.jobTitle = jobTitle;
       this.payRate = payRate;
   }

   public String getName() {
       return name;
   }

   public String getJobTitle() {
       return jobTitle;
   }

   public double getPayRate() {
       return payRate;
   }
  
   public String toString() {
       return "Name: "+name+" Job Title: "+jobTitle+"   Pay Rate: "+payRate;
   }
}