Examlex

Solved

Programming
Write a Static Method Named PrintTwoDigit That Accepts a Random

question 1

Essay

Programming
Write a static method named printTwoDigit that accepts a Random object and an integer n as parameters and that prints a series of n randomly generated two-digit numbers. The method should use the Random object to select numbers in the range of 10 to 99 inclusive where each number is equally likely to be chosen. After displaying each number that was produced, the method should indicate whether the number 42 was ever selected ("we saw a 42!") or not ("no 42 was seen."). You may assume that the value of n passed is at least 0.
The following table shows two sample calls and their output:
 Call  Random r= new Random (); print TwoDigit (r,4); Random r= new Random ( ):  Orint TwoDigit (r,7); Output  next =52 next =83 next =10 next =29 next =96 next =42 next =86 next =22 no 42 was seen.  next =91 next =36 next =73 we saw a 42!\begin{array}{l|l|l}\text { Call } & \begin{array}{l}\text { Random } r=\text { new Random }() ; \\\text { print TwoDigit }(r, 4) ;\end{array} & \begin{array}{l}\text { Random } r=\text { new Random ( ): } \\\text { Orint TwoDigit }(r, 7) ;\end{array} \\\hline \text { Output } & \text { next }=52 & \text { next }=83 \\&\text { next }=10 & \text { next }=29 \\&\text { next }=96 & \text { next }=42 \\&\text { next }=86 & \text { next }=22 \\&\text { no } 42 \text { was seen. } & \text { next }=91 \\& & \text { next }=36 \\&&\text { next }=73 \\& & \text { we saw a } 42 !\end{array}


Definitions:

Genetically Engrained

Traits or characteristics that are deeply embedded in an individual's genetic makeup.

Human Paradigms

Foundational models or patterns of thinking that guide human behavior and understanding of the world.

Concept of Race

A socially constructed categorization of humans based on physical characteristics, ancestry, and genetics, often used to classify and differentiate individuals and groups.

Physical Differences

Physical differences refer to the variations in the bodily structure, function, or appearance among individuals or between groups.

Related Questions