1.
When you run your RandomNumber.frm program, do you get the same exact results as the example shown on the direction sheet?
Correct Answer
B. No
Explanation
The answer is "No" because when running the RandomNumber.frm program, the results may vary due to the nature of random numbers. Random numbers are generated based on certain algorithms and seed values, so each time the program is run, it may produce different results. Therefore, it is unlikely that the exact same results as the example shown on the direction sheet will be obtained.
2.
Why or why not?
Correct Answer
B. The output is different because the numbers are random.
Explanation
The given correct answer states that the output is different because the numbers are random. This implies that the outcome of the task or calculation is influenced by the random nature of the numbers involved. As a result, even if the person claims to have completed the task correctly, the randomness of the numbers used would still lead to a different output. Therefore, the correct answer suggests that the randomness of the numbers is the reason for the difference in output.
3.
What line in the code makes cmdLessOne produce a decimal?
Correct Answer
A. Dim LessOne As Single
Explanation
Single is the data type for decimal numbers and the variable LessOne is declared as a Single in this declaration statement.
4.
What line in the code makes cmdTen produce a decimal?
Correct Answer
A. Dim LessTen As Single
Explanation
Single is the data type for decimal numbers and the variable LessTen is declared as a Single in this declaration statement.
5.
What line in the code makes cmdFive produce an integer?
Correct Answer
A. Dim UpTo5 As Integer
Explanation
Integer is the data type for integer numbers and the variable UpTo5 is declared as a Integer in this declaration statement.
6.
What line in the code makes cmd100 produce an integer?
Correct Answer
A. Dim UpTo100 As Integer
Explanation
Integer is the data type for integer numbers and the variable UpTo100 is declared as a Integer in this declaration statement.
7.
What line of code guarantees that the results will be truly random?
Correct Answer
B. Randomize
Explanation
The line of code "Randomize" guarantees that the results will be truly random. This function initializes the random number generator with a seed value based on the system timer. By calling this function before generating random numbers, it ensures that each time the program runs, a different seed value is used, resulting in a different sequence of random numbers.
8.
What is the keyword in Visual Basic that produces a random number between 0 and 1?
Correct Answer
B. Rnd
Explanation
The keyword in Visual Basic that produces a random number between 0 and 1 is "Rnd". This keyword is used in conjunction with the "Randomize" keyword to initialize the random number generator. By calling "Rnd", a random number between 0 and 1 is generated.
9.
What type of numbers exist between 0 and 1?
Correct Answer
B. Decimals (Single)
Explanation
The correct answer is "Decimals (Single)" because between 0 and 1, there are a range of numbers that are not whole numbers or integers. These numbers are called decimals, and in this case, specifically "single" decimals, which means they have only one digit after the decimal point. Decimals represent fractions or parts of a whole number, allowing for more precise representation of values between whole numbers.
10.
When you multiply a number between 0 and 1 by 10, how many digits are to the left of the decimal point?
Correct Answer
B. 1
Explanation
Example: .34201 * 10 results in 3.4201 The 3 is the only digit to the left of the decimal point.
11.
Describe the number that will be stored in memory because of this line of code in cmdTen. LessTen = 10 * Rnd
Correct Answer
A. A random decimal number less than 10 such as 2.3482 or 9.3627
Explanation
Example: 10 * .34201 results in 3.4201
Example: 10 * .9999 results in 9.999
Example: 10 * .1047 results in 1.047
Example: 10 * .00005 results in 0.0005
12.
Describe the number that will be stored in the variable, UpTo5, because of this line of code in cmdFive. UpTo5 = 5 * Rnd
Correct Answer
C. A random integer from 0 to 5
Explanation
Since UpTo5 is declared as an integer whatever number is stored in it must be an integer. When an attempt to store a decimal occurs, the digits after the decimal point will be chopped off. Depending on the programming language the number might be rounded to the nearest integer.
Example: 5 * .00005 results in .00025 which rounds to 0 Example: 5 * .1047 results in .5235 which rounds to 1
Example: 5 * .34201 results in 1.71005 which rounds to 2
Example: 5 * .541 results in 2.705 which rounds to 3
Example: 5 * .6 results in 3
Example: 5 * .8 results in 4
Example: 5 * .987 results in 4.935 which rounds to 5
13.
What must Rnd be multiplied by to produce a number between 0 and 33?
Correct Answer
D. 33
Explanation
Example: 33 * .1 results in 3.3
Example: 33 * .5 results in 16.5
Example: 33 * .9999 results in 32.9967
14.
Write the line of code that will put a random number between 0 and 33 in the variable, UpTo33.
Correct Answer
B. UpTo33 = 33 * Rnd
Explanation
To get a random number between 0 and any number x, multiply Rnd by that number x.
15.
To have a program user pick the highest number, use a textbox to get the number and multiply Rnd by the numerical variable where that number is stored.
Correct Answer
A. True
Explanation
This statement is true because to have a program user pick the highest number, we can use a textbox to get the number input from the user. Then, we can generate a random number using the Rnd function and multiply it by the numerical variable where the highest number is stored. This way, we can ensure that the user picks the highest number based on the random value generated.
16.
Which of these could be the assignment statement for putting the random integer from 0 to the top number the user provided, into a variable in memory, if these declarations are given?Dim Top As IntegerDim UpToTop As Integer
Correct Answer
B. UpToTop = Top * Rnd
Explanation
To get a random number between 0 and a number in the variable Top, multiply Rnd by the variable Top.