1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
balandron [24]
3 years ago
5

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

alized String. (4 points)
while(answer.equals("N"))
{
// code not shown
}

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? (4 points)

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



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? (4 points)


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)
Computers and Technology
1 answer:
stellarik [79]3 years ago
3 0

<u>Answer:</u>

<em>1. The loop will run unless the value of answer equals to Capital N.</em> The method equals is “case-sensitive” that is lower case letter and upper case letters are considered different. That “a” and “A” means the same to us, but for the method equals it is different and equals method will return false if the case is not matching.

<em>2. a (int)(Math.random() * (upper − lower) ) + lower </em>

Since we need to consider the lower limit value together to get the desired results we need to add the value of lower limit to the multiplied answer.

<em>3. b while(userGuess != secretNumber || userGuess >= lowerLimit && userGuess <= upperLimit)</em>

Here the program is required to check the while loop and exit when user guess the number or we can say the loop should continue until the user guess the number, so that is why we have taken <em>userGuess!=secretNumber. </em>Next the loop should be exited if it is not within the range or we can say that the loop should run only if the guessed number is within the upper and lower limit.<em> That is why we have opted for the condition userGues>=lowerlimit && userGuess<=upperlimit.</em> Why we have taken && as the operator is that, it’s a range of values so && operator best suit for this kind of logical condition.

You might be interested in
Does anyone know how I can make this return a double with 2 decimal places?
dolphi86 [110]

hi :)   .,..............

Explanation:

8 0
3 years ago
Can someone take away your points
Julli [10]

Answer:

no why do you ask.. . ...........

7 0
3 years ago
I recently went up in rank on Brainly and im wondering, if i use 70 pts will i go back to being a beginner?
Naddika [18.5K]
No i don't think so.
7 0
3 years ago
Read 2 more answers
3 items that were on Ken’s “big human bee movie
Pie

Answer:

all my special skills, my top 10 favorite movies, I predicted global warming

hope it helped

Explanation:

6 0
4 years ago
Question 7 (1 point)
Vlada [557]

Answer:

technical knowledge

Explanation:

8 0
3 years ago
Other questions:
  • Which letters appear in the home row on a keyboard?
    14·2 answers
  • The following code is intended to calculate the sum of the first five positive odd integers. int sum = 0, k; for (k = 1; k &lt;=
    10·1 answer
  • What is a benefit of Virtualization for organizations?
    15·2 answers
  • Let’s use that simple branch instruction to do the following: Load the two words declared in the data statement shown to the rig
    14·1 answer
  • There are 4 classrooms for fifth grade and 4 classrooms for sixth grade at a school. Each classroom has 20 students. A teacher i
    13·2 answers
  • Which of the following is not a valid C language<br>int​
    6·1 answer
  • I umm… really need helpp<br> Can someone help me out <br> I’ll even mark u as brainiest !
    12·1 answer
  • Which of the following is true about named ranges?
    6·1 answer
  • What is the full form of MPEG?<br> The full form for MPEG is ________.
    9·1 answer
  • What would be the most professional choice of words for your response:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!