Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to write a JAVA code , please HELP! I am posting the starter code, help me please to fill out the TO DO

I need to write a JAVA code , please HELP!

I am posting the starter code, help me please to fill out the TO DO parts

also I am posting the result I need to create

thanks

HERE IS THE STARTER CODE (TWO PARTS)

import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random;

public class InterviewQuestionsTest {

private static Random r; static { r=new Random(2); } public static int [] GetRandomArray(int n, int min, int max) { int []a=new int[n]; for(int i=0; i getNRandomNames(int n, ArrayListnameList) { ArrayList friendList=new ArrayList(); for(int i=0; inameList) { System.out.print(name+"'s Friend List: "); for(var n : nameList) { System.out.print(n+", "); } System.out.println(); } public static void makeEvenAllThenOddAll(int []numbers, int pos) { for(int i=0; inameList= new ArrayList<>(List.of( "Liam", "Noah", "Oliver", "William","Elijah","James","Benjamin","Lucas","Mason","Ethan","Alexander","Henry","Jacob","Michael", "Daniel", "Logan","Jackson","Sebastian","Jack","Aiden","Owen","Samuel","Matthew","Joseph","Levi","Mateo","David","John","Wyatt")); ArrayList davidsFriends=getNRandomNames(10,nameList); displayNames("David", davidsFriends); ArrayList susansFriends=getNRandomNames(10,nameList); displayNames("Susan", susansFriends); ArrayList commonFriends=solution.commonFriends(davidsFriends, susansFriends); displayNames("Common Friends", commonFriends); System.out.println(" Problem Three: Count Divisors"); n=6; int []values=GetRandomArray(n, 5, 20); displayIntArray(values); System.out.println(" Count: "+solution.countDivisors(values)); n=10; System.out.println(" Problem Four: First Odd Number"); int []numbers=GetRandomArray(n, 10, 50); makeEvenAllThenOddAll(numbers, r.nextInt(n)); displayIntArray(numbers); System.out.println(" First odd number's index is: "+solution.findIndexOfFirstOddNumber(numbers)); }

}

THIS IS THE SECOND PART AND HERE IS WHERE MY CODE NEED GO

import java.util.ArrayList;

public class InterviewQuestions {

public int findPriceyNeighbours(double[] prices)

{

//TO DO

return -1;

}

public ArrayList commonFriends(ArrayList friendListOne, ArrayList friendListTwo)

{

ArrayList common=new ArrayList();

//ToDo

return common;

}

public int countDivisors(int[] values)

{

//ToDo

return -1;

}

public int findIndexOfFirstOddNumber(int[] numbers)

{

//ToDo

return -1;

}

}

This is the result that should come out

/*If you have implemented your GLA correctly, the following will be your program's output:

Problem One: Pricey Neighbours

House Prices:

622968.00

520112.00

840169.00

925050.00

916256.00

909680.00

650372.00

979577.00

656166.00

891104.00

First index of Pricey Neighbours is: 3

Problem Two: Common Friends

David's Friend List: Jacob, Benjamin, Joseph, Owen, Michael, Lucas, Wyatt, Owen, Jacob, Alexander,

Susan's Friend List: Jack, Alexander, Samuel, Henry, Daniel, Logan, Joseph, Benjamin, Sebastian, Wyatt,

Common Friends's Friend List: Benjamin, Joseph, Wyatt, Alexander,

Problem Three: Count Divisors

10 13 20 15 13 10

Count: 3

Problem Four: First Odd Number

16 20 40 12 35 19 23 31 35 11

First odd number's index is: 4

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Create a workflow analysis.

Answered: 1 week ago