Course Hero Logo
Question
Answered step-by-step

  Question 2: TMax 2a) Generate a random array In TMax.java,...

Image transcription text

public class TMax { public static void main (String args) { int seed = Integer . parseInt (args[0]) ; int array = getRandomArray (seed) ; System . out . printin (thirdBiggest (array) ) ; public static int getRandomArray (long seed) { int lowerBound = 2; int upperBound = 10; / / TODO change only the following part. return null; public static double thirdBiggest (int array) { / / TODO change only the following part. return 0.0;

... Show more

 

Question 2: TMax
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. In the case of having less than three numbers that are
bigger than the rest of the elements, you should return the maximum.
Test case 1:
a -> [0.123, 0.235, 0.3573, 0.657]
thirdBiggest(a) -> 0.235
Test case 2:
a -> [0.067, 0.235]
As explained above in this case we should return the Maximum number.
Therefore:
thirdBiggest(a) -> 0.235

Answer & Explanation
Verified Solved by verified expert

sum do

ce 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,

Unlock full access to Course Hero

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

Subscribe to view answer
Step-by-step explanation

o.

gue

ac, dictum vitae odi

gue

m ipsum dolor sit amet, consectetur ad

gue

usce dui

gue

acinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie conse

gue

molestie consequat, ultrices ac magna. Fusce dui lec

gue

itur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus,

gue

ic

gue

lestie cons

gue

ongue vel laoreet a

a. Fusce dui lectus, congue v

cing elit. Nam lacinia pulvinar

gue

acinia pulvinar t

m ipsum

ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, conse

cing elit. Nam lacinia pulvinar tortor nec facil

m risus ante, dapibus a molestie consequat, ultri

facilisis. Pellentesque dapibus efficitur laoreet. N

itur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac m

nec facilisis. Pellentesque da

onec aliquet. Lorem ipsum dolor sit

s ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lect

nec facilisis. Pellentesque da

ipsum dolor sit amet, consectetur adipiscing

m ipsum dolor sit ame

acinia pulvinar t

acinia pulvinar t

gue

amet, consectetur adipiscing elit. Nam lacinia pulvinar tort

ce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. L

facilisis. Pellentesque dapibus efficitur laoreet. Nam

rem ipsum dolor sit amet, consectetur adipiscing elit.

usce dui lectus, congue vel laoreet ac, dictum vitae odio. Don

consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facili

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum v

usce dui lectus, congue vel laoreet ac

usce dui lectus, congue vel laoreet ac

sus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congu

ur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna.

ce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet.

molestie consequat, ultrices ac magna. Fusce dui lectus, congue v

facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molest

risus ante, dapibus a molestie consequat, ultrices ac magna.

pulvinar tortor nec facilisis. Pellentesque dapibus effici

gue

pulvinar tortor nec facilisis. Pellentesque dapibus effici

molestie consequat, ultrices ac magna. Fusce dui lectus, congue v

trices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum d

ce dui lectus, congue vel laoreet ac, dictum vit

tesque dapibus efficitur laoreet. Nam ris

gue

entesque dapibus efficitur laoreet. Nam risus ante,

m ipsum dolor sit ame

acinia pulvinar t

acinia pulvinar t

acinia pulvinar t

ec facilisis. Pellentesque dapibus eff

ctum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet

sum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar

, consectetur adipiscing elit. Nam lacinia pulvinar tort

ongue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consec

ctum vitae odio. Donec aliquet. Lorem ipsum

Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor si

gue

llentesque dapibus efficitur laoreet. Nam risus ante, dapibu

ur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac m

acinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus

tesque dapibus efficitur laoreet. Nam ris

risus ante, dapibus a molestie consequat, ultrices ac magna.

gue

m ipsum dolor sit ame

gue

o

sum do

return arr; } Main.java 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 } // main method public static v

ris

} Main.java 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 // main method public static void main(String[] args) { double

ac, dictum vitae odio

gue

ipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultri

Fusce dui lectus, congue vel laoreet

risus ante, dapibus a molestie conseq

tesque dapibus efficitur

o. Donec aliquet. Lorem ipsum dolor

Biggest : 0.672 0.141 0.672 thirdBiggest : 0.829 0.296 0.299 0.512 0.599 0.637 0.767 0.822 0.829 0.915 0.974 thirdBiggest : 0

3 Attachments
image.png
png
image.png
png
image.png
png