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 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen tool
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 24.06.2019 08:00
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
question
Computers and Technology, 24.06.2019 08:30
Aconsumer would pay an extra they used the rent to own program to buy the computer, rather than using cash. for all of the items, is the cheapest option over the life of the contract. the most expensive overall option is to use purchase the item.
Answers: 2
You know the right answer?
Question 1 Errors can be syntax errors or logic errors (the code works, but not as intended).
...
Questions
Questions on the website: 13722360