Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/* Method one2TwoD: (Problem 2) 10 pts * Given a ld array of integers A, you are to produce (and return) a 2D array B
/* Method one2TwoD: (Problem 2) 10 pts * Given a ld array of integers A, you are to produce (and return) a 2D array B of integers that is as follows: B has as many rows as A.length B has as many columns as A.length B contains only values o except for its diagonal elements: for all elements B[i][i], we have B[i][i] = A[i]. * Note: you get bonus points when you implement this method using only one for loop. -- 3 pts */ public int[][] one2TwoD(int[] A) { int[][] B = new int[1][1]; // to be modified of course :) return ""; } /* Method one2TwoDMulti: (Problem 3) 10 pts * Given a ld array of integers A, you are to produce (and return) a 2D array B of positive integers that is as follows: B has as many rows as A.length Each ith row of B is of length A[i] and contains only values A[i] public int[][] one2TwoDMulti(int[] A) { int[] [] B = new int[1][1]; // to be modified of course :) return B; } /* Method string2Array: (Problem 4) 10 pts * Given a string str, you are to produce (and return) a ld array s of strings of length = the length of str, * and where each element S[i] = str.substring(0,1+1). */ public String[] string2Array(String str) { String[] $ = new String[1]; // to be modified of course :) return s; } /******For testing one2TwoD int[] z = {1, 2, 5, 3}; int[][] B testing.one2TwoD(z); for (int i 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started