(Solved) : Two Bottom Pictures Part Starter Code Problem Talking Language Java Q42675169 . . .

Problem: Zipper For this problem, you have some starter code. Save it and run it a few times -- you will see that it generateimport java.util. Randam; import java.util.Arrays; public class Zipper { * TO DO for LAB 12 * Returns an array which containsThe two bottom pictures is part of the samestarter code the problem is talking about(Language is Java)

Problem: Zipper For this problem, you have some starter code. Save it and run it a few times — you will see that it generates two arrays of equal lengths populated with random values in range [0,9]. Your task is to complete the zip() method, which takes two equal length arrays and “zips” them. See sample runs below and comments in the starter code for further description of what that means. Input Validation: • None – there is no user input. Requirements: . Do not change anything in the starter code other than the body of the zip () method. (Although you may add helper methods if you want.) Sample runs: Weron DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arrl is [] arr2 is [] arr3 is [] Weron@DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arri is [3, 8] arr2 is [9, 3] arr3 is [3, 9, 8, 3] Weron DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java Zipper arri is [7, 1, 4, 2, 6] arr2 is [3, 6, 4, 3, 5] arr3 is [7, 3, 1, 6, 4, 4, 2, 3, 6, 5] WeronCDESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arrl is (5, arr2 is [5, 2] arr3 is [5, 5, 6, 2] Weron@DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java Zipper arri is [] arr2 is [] arr3 is [] import java.util. Randam; import java.util.Arrays; public class Zipper { * TO DO for LAB 12 * Returns an array which contains “zipped” * contents of arrays a and b. * For example, if a is [1, 2] and bis [33, 44) + the returned array is 11, 33, 2, 441 * (The elements of a are at even indices and * the elements of bare at odd indices.) public static int[] zip(int[] a, int[] b) { // TO DO for LAB 12 return null; // Change this! public static void main(String[] args) { // Generate an array for at moat 5 ints int[] arrl = nextArray(5); // Fill out the array with values [0, 9] populateArray(arrl, 9); System.out.print(‘arri is “); System.out.println(Arrays.toString(arrl)); 1/ Generate an array exactly the same lenght // as the one created above int[] arr2 = new int[arri.length]; populateArray(arr2, 9); System.out.print(‘arr2 is “); System.out.println(Arrays.toString(arr2)); intu arr3 = zip(arri, arr2); System.out.print(‘arr3 is “); System.out.println(Arrays.toString(arr3)); * Creates and returns an empty array for + at most maxlength ints. public static int[nextArray(int maxlength) { Random r – new Random(); int length = r.nextInt (maxlength + 1); We were unable to transcribe this imageShow transcribed image text Problem: Zipper For this problem, you have some starter code. Save it and run it a few times — you will see that it generates two arrays of equal lengths populated with random values in range [0,9]. Your task is to complete the zip() method, which takes two equal length arrays and “zips” them. See sample runs below and comments in the starter code for further description of what that means. Input Validation: • None – there is no user input. Requirements: . Do not change anything in the starter code other than the body of the zip () method. (Although you may add helper methods if you want.) Sample runs: Weron DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arrl is [] arr2 is [] arr3 is [] Weron@DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arri is [3, 8] arr2 is [9, 3] arr3 is [3, 9, 8, 3] Weron DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java Zipper arri is [7, 1, 4, 2, 6] arr2 is [3, 6, 4, 3, 5] arr3 is [7, 3, 1, 6, 4, 4, 2, 3, 6, 5] WeronCDESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java zipper arrl is (5, arr2 is [5, 2] arr3 is [5, 5, 6, 2] Weron@DESKTOP-218KDUL MINGW64 -/OneDrive/Documents/ $ java Zipper arri is [] arr2 is [] arr3 is []
import java.util. Randam; import java.util.Arrays; public class Zipper { * TO DO for LAB 12 * Returns an array which contains “zipped” * contents of arrays a and b. * For example, if a is [1, 2] and bis [33, 44) + the returned array is 11, 33, 2, 441 * (The elements of a are at even indices and * the elements of bare at odd indices.) public static int[] zip(int[] a, int[] b) { // TO DO for LAB 12 return null; // Change this! public static void main(String[] args) { // Generate an array for at moat 5 ints int[] arrl = nextArray(5); // Fill out the array with values [0, 9] populateArray(arrl, 9); System.out.print(‘arri is “); System.out.println(Arrays.toString(arrl)); 1/ Generate an array exactly the same lenght // as the one created above int[] arr2 = new int[arri.length]; populateArray(arr2, 9); System.out.print(‘arr2 is “); System.out.println(Arrays.toString(arr2)); intu arr3 = zip(arri, arr2); System.out.print(‘arr3 is “); System.out.println(Arrays.toString(arr3)); * Creates and returns an empty array for + at most maxlength ints. public static int[nextArray(int maxlength) { Random r – new Random(); int length = r.nextInt (maxlength + 1);

Expert Answer


Answer to The two bottom pictures is part of the same starter code the problem is talking about(Language is Java)…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?