Question: Please write code in java ! Array size 1 0 Several valid approaches exist to code this assignment; the pseudocode below stores integers in the
Please write code in java
Array size
Several valid approaches exist to code this assignment; the pseudocode below stores integers in the histogramarray that represent the number of times a random digit was generated corresponding to the index of histogramarray. For example, a in the zeroth element of the histogramarray indicates that the digit was randomly generated fourteen times.
Get a userdefined seed.
Create a random object using a userdefined seed.
Get the number of userdefined data points.
Using a loop, initialize the histogramarray with zeros in all elements.
Note: This is not necessary for an array that stores the primitiveint values since, by default, all elements of an array that store the primitiveint data type are initialized to zero.
Using a loop, update the histogramarray with integers that represent the number of occurrences counter of a random digit corresponding to the histogramarray index.
For example:
If the first random digit is a then increment the value in the sizth element by one:
If the second random digit is a then increment the value in the zeroth element by one:
If the third random digit is a then increment the value in the ninth element by one:
If the fourth random digit is a then increment the value in the sizth element by one:
If the fifth random digit is a then increment the value in the sizth element by one:
If the sixth random digit is a then increment the value in the zeroth element by one:
etc.
Using a loop, display
the histogramarray index corresponding to a random digit for the current index followed by
a sequence of dashes using an innerloop nested loops that correspond to the number of occurrences of the histogramarray current index followed by
the integer that corresponds to the number of occurrences of the histogramarray current index.
For example:
if the eighth element stores a then you need to print followed by three dashes and the integer three.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
