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

I need this code to compile, utilize arrays, and have the following output when

ID: 3539286 • Letter: I

Question

I need this code to compile, utilize arrays, and have the following output when the word "doe" is searched:


Found matching last name at index: 1

The full name is: John Doe

Age is: 25

Salary is: $30,000.00

Zip code is: 12204

Found matching last name at index: 2

The full name is: Jane Doe

Age is: 26

Salary is: $40,000.00

Zip code is: 12205


Please fix this code:


import java.text.NumberFormat;

import java.util.ArrayList;

public class Assignment8 {

public static void main(String[] args)

{

String[] fullName = new String[]{ "John Smith","John Doe", "Jane Doe", "Jane Smith" };

ArrayList<Integer> indexList = new ArrayList<Integer>();

int[] age = {24, 25,26,27};

double[] salary = {20000, 30000, 40000, 50000};

int[] zipcode = {12204, 12205, 12206, 12207};

// call user defined methods

findIndexofArrayWithLastNameDoe(fullName, indexList);

int x;

for (x = 0; x < fullName.length; x++) {String[] names = fullName[x].split(" ");

}

printInformation(fullName, age, salary, indexList);

}

public static void findIndexofArrayWithLastNameDoe(String[] fullName,

ArrayList<Integer> indexList)

{

}

if (names[1].equals("Doe")) {indexList.add(x);

}

private static void printInformation(String[] fullName, int[] age,

double[] salary , int[] zipcode, ArrayList<Integer> indexList) {for (Integer x: indexList) {System.out.println("Found matching last name at index: " + x );

System.out.println("The full name is: " + fullName[x]);

System.out.println("Age is: " + age[x]);

System.out.println("Salary is:" + salary [x]);

NumberFormat formatter = NumberFormat.getCurrencyInstance();

System.out.println("Zip code is:" + zipcode[x]);

}

}

}


Please provide a complete, compilable solution and you will receive the points and 5 stars.

Explanation / Answer

import java.text.NumberFormat;

import java.util.ArrayList;


public class Assignment8 {

public static ArrayList<Integer> findIndexofArrayWithLastNameDoe(String[] fullName, ArrayList<Integer> indexList) {

int x;

for (x = 0; x < fullName.length; x++) {

String[] names = fullName[x].split(" ");


if (names[1].equals("Doe")) {

indexList.add(x);

}

}

return indexList;

}

public static void printInformation(String[] fullName, int[] age, double[] salary , int[] zipcode, ArrayList<Integer> indexList) {

for (Integer x: indexList) {

System.out.println("Found matching last name at index: " + x );


System.out.println("The full name is: " + fullName[x]);


System.out.println("Age is: " + age[x]);


System.out.println("Salary is:" + salary [x]);


NumberFormat formatter = NumberFormat.getCurrencyInstance();


System.out.println("Zip code is:" + zipcode[x]);

}

}


public static void main(String[] args) {

String[] fullName = new String[]{ "John Smith","John Doe", "Jane Doe", "Jane Smith" };

ArrayList<Integer> indexList = new ArrayList<Integer>();

int[] age = {24,25,26,27};

double[] salary = {20000.0, 30000.0, 40000.0, 50000.0};

int[] zipcode = {12204, 12205, 12206, 12207};

// call user defined methods

indexList = findIndexofArrayWithLastNameDoe(fullName, indexList);

for (Integer x: indexList) {

System.out.println("Found matching last name at index: " + x );


System.out.println("The full name is: " + fullName[x]);


System.out.println("Age is: " + age[x]);


System.out.println("Salary is:" + salary [x]);


NumberFormat formatter = NumberFormat.getCurrencyInstance();


System.out.println("Zip code is:" + zipcode[x]);

}

}

}

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