subject

Question 1 Errors can be syntax errors or logic errors (the code works, but not as intended).

In the Guess My Number game, there is a lower limit and an upper limit for the range of possible numbers to guess. If the lower limit were exclusive and the upper limit inclusive, which expression would properly generate values for the secret number?

A) (int)(Math. random() * (upper βˆ’ lower) ) + lower
B) (int)(Math. random() * (upper βˆ’ lower + 1) ) + lower
C) (int)(Math. random() * (upper βˆ’ lower) ) + lower + 1
D) (int)(Math. random() * (upper βˆ’ 1 βˆ’ lower) ) + lower + 1
E) (int)(Math. random() * (upper βˆ’ lower + 1) ) + lower - 1

Question 2
Errors can be syntax errors or logic errors (the code works, but not as intended).

What conclusion can be made about the state of the program when the while loop terminates? Assume answer is a declared and initialized String.

while(answer. equals("N"))
{
// code not shown
}

A) The value of answer is N
B) The value of answer is n or N
C) The value of answer is not N
D) The value of answer is Y
E) Nothing can be determined

Question 3
Errors can be syntax errors or logic errors (the code works, but not as intended).

Which of the following is equivalent to while(userGuess != secretNumber)?

I) while( userGuess < secretNumber && userGuess > secretNumber)
II) while( userGuess < secretNumber || userGuess > secretNumber)
III) while( !(userGuess == secretNumber) )

I only
II only
III only
I and III only
II and III only

Question 4
Errors can be syntax errors or logic errors (the code works, but not as intended).

In the Guess My Number program, the user continues guessing numbers until the secret number is matched. The program needs to be modified to include an extra criterion that requires all guesses to be within the lower and upper bounds. If the user guesses below or above the range of the secret number, the while terminates. How would the while statement be modified to include the new criterion?

A) while(userGuess != secretNumber || userGuess >= lowerLimit || userGuess <= upperLimit)
B) while(userGuess != secretNumber || userGuess >= lowerLimit && userGuess <= upperLimit)
C) while(userGuess != secretNumber && userGuess >= lowerLimit && userGuess <= upperLimit)
D) while(userGuess == secretNumber || userGuess >= lowerLimit && userGuess <= upperLimit)
E) while(userGuess == secretNumber && userGuess >= lowerLimit || userGuess <= upperLimit)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:00
Our primary purpouse as electricians is to do wich of the following core concepts? a: install electrical components in a way they can be upgraded b: install electrical equiptment in a way that reduces heat c: install electrical systems in a safe manner d: only b and c
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
question
Computers and Technology, 24.06.2019 08:50
Write a program that will compute the volume of ice cream served in a cone. as you can see in the diagram below, the ice cream is served as a hemisphere of frozen deliciousness on top of a cone, which is also packed with frozen deliciousness. thus, the total volume of ice cream sold is the volume of the hemisphere plus the volume of the cone. the example shows an ice cream cone in which the hemisphere and cone have a radius of 10 inches and the cone has a height of 15 inches. your program must instead prompt for these two values, which are taken from the keyboard as integers: β€’ the hemisphere/cone radius in inches, and
Answers: 3
question
Computers and Technology, 24.06.2019 13:20
In the insert table dialog box, you select the checkbox to create the first row as the header of the table.
Answers: 3
You know the right answer?
Question 1 Errors can be syntax errors or logic errors (the code works, but not as intended).
...
Questions
question
Advanced Placement (AP), 25.01.2021 09:10
question
Mathematics, 25.01.2021 09:10
question
SAT, 25.01.2021 09:10
Questions on the website: 13722359