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 exclusive, which expression would properly generate values for the secret number?

(int)(math. random() * (upper − lower) ) + lower
(int)(math. random() * (upper − lower + 1) ) + lower
(int)(math. random() * (upper − lower) ) + lower + 1
(int)(math. random() * (upper − 1 − lower) ) + lower + 1
(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).

which of the following is equivalent to while( ! (userguess == secretnumber) )?

while( userguess ! = secretnumber )
while(userguess < secretnumber || userguess > secretnumber)
while( userguess < secretnumber & & userguess > secretnumber)
i only
ii only
iii only
i and ii only
i and iii only

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

after execution of the following code segment, what will be displayed?

int x = 15;
while(x > 0)
{
x −= 6;
}
system. out. println(x);

−6
−3
0
3
15

question 4
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
}

the value of answer is n
the value of answer is n or n
the value of answer is not n
the value of answer is y
nothing can be determined

question 5
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. assuming numguesses is initialized to 1, how would the while statement be modified to include an extra criterion limiting the number of guesses to 15?

while( (userguess == secretnumber) || numguesses < 14 )
while( (userguess== secretnumber) & & numguesses < = 15 )
while( ! (userguess == secretnumber) || numguesses < 15 )
while( ! (userguess == secretnumber) & & numguesses < = 15 )
while( ! (userguess == secretnumber) & & numguesses < 15 )

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
By refraining from constructing a building until they are certain that it will not cause harm to the environment, an organization is adhering to the
Answers: 2
question
Computers and Technology, 22.06.2019 15:20
The north and south regions had very diferent economies in the 1800s.
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of “tag” to remember the meaning of contagious
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