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 05:00
Lisa has a section of her document that she would like to include in the index. which option should lisa choose? mark index mark entry insert endnote add text
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 24.06.2019 06:30
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
question
Computers and Technology, 24.06.2019 14:40
Create a function (prob3_6) that will do the following: input a positive scalar integer x. if x is odd, multiply it by 3 and add 1. if the given x is even, divide it by 2. repeat this rule on the new value until you get 1, if ever. your program will output how many operations it had to perform to get to 1 and the largest number along the way. for example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 16. we divide 16 (even) by two giving 8. we divide 8 (even) by two giving 4. we divide 4 (even) by two giving 2. we divide 2 (even) by 2 to give us 1. once we have one, we stop. this example took seven operations to get to one. the largest number we had along the way was 16. every value of n that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the collatz conjectureopens in new tab) whether every value of n eventually leads to 1. your program should include a while loop and an if-statement.
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
Mathematics, 19.07.2019 15:00