Question

# Part 2 The questions in this part of the assignment will be graded....

Part 2

The questions in this part of the assignment will be graded.

First, you should download the attached java files to this assignment from MyCourses.

Question 1: ArraySum            (30 points)

1a) Method to transform a number of an array

In ArraySum calss, write a method called transform that receives an integer number and transforms it to an integer array such that the array elements are digits of input integer number.

For example:

int [] transform(1234) should return the integer array [1, 2, 3, 4]

1b) Method to compute the sum of two arrays that represent a very big number.

In ArraySum class, write a method called sum that receives two integer arrays of equal size (each of these arrays is created by transformmethod) and returns an array of integer digits that corresponds to the sum.

Algorithm for sum function: In math, we first add digits at the rightmost index "i".  If result of "digits addition" is greater than 9 then, we have a carry that needs to be added to digits at index "i-1" location, and so on, to complete addition digit by digit.

Example:

transform(1234) -> a which is [1, 2, 3, 4]

transform(1211) -> b which is [1, 2, 1, 1]

sum(a, b) -> [2,4,4,5]

transform(9295) -> x which is [9, 2, 9, 5]

sum(a, x) -> [1,0,5,2,9]

Question 2: TMax            (40 points)

2a) Generate a random array

In TMax.java, complete the getRandomArray() method that is responsible to generate a one dimensional random array with the size of a random number between 2 and 10. Then populate the Array with some random real values from [0, 1].

Note: you can set the seed by using the args in the main method.

Output examples:

The output results might be varied depends on the seed that you are using.

getRandomArray() -> [0.123, 0.235, 0.3573, 0.657] getRandomArray()     ->       [0.067, 0.235, 0.657]

2b) Find the third biggest number in the array

Then, complete thirdBiggest(int[] array). This method should accept an array that we generated above and return the third biggest number in this array. When array has only two numbers then the function should return bigger of these two.

Test case 1:

a -> [0.123, 0.235, 0.3573, 0.657] thirdBiggest(a) -> 0.235

Test case 2:

a -> [0.067, 0.235]

thirdBiggest(a) -> 0.235

Question 3: Rotate a 2D Array     (30 points)

In Rotate.java, complete the method of rotate180. The method receives a 2D array of integers and rotates the given 2D array in 1800 degrees (clockwise).

Assume matrix "a" represent a 2D array as follows:

After running the rotate180(a) the matrix should be changed (in-place) such that it has 180 degrees rotation of elements.

Therefore, after running rotate180(a) the matrix "a" will change to the following matrix:

What To Submit

Please put all your files in a folder called Assignment3. Zip the folder (DO NOT RAR it) and submit it through MyCourses.

Inside your zipped folder, there must be only the following files. Do not submit any other files, especially .class files. Any deviation from these requirements may lead to lost marks.

ArraySum.java

TMax.java

Rotate.java

Confession.txt (optional) In this file, you can tell the TA about any issues you ran into doing this assignment.

Note that the Assignment3 folder must not contain any subfolder!

Solved by verified expert
<p>ctum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, c</p> Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet

Explore over 16 million step-by-step answers from our library

`ec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, c`

gue

m ipsum dolo

`a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus effici`

gue

amet, consectet

`fficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices`
Step-by-step explanation

, dictum vitae o

gue

sum dolor si

gue

iscing elit. Nam

gue

3 Attachments
PNG
PNG
PNG
Student reviews
100% (2 ratings)