answer.
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]
2 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]2 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
Suppose that the following processes arrive for execution at the times indicated. Each process will run for the amount of time l
Len [333]

Answer:

a) 10.53

b) 9.53

Explanation:

a) Average Turnaround Time: ( (8-0)+(12-0.4)+(13-1.0) ) / 3 = 10.53

b) Average Turnaround Time: ( (8-0)+(13-0.4)+(9-1.0) ) / 3 = 9.53

5 0
2 years ago
Determine the value of X if (211) base x = (152) base 8, how to do this?
Alex
 we translate the following statement given in terms of logarithms. 211 base x can be expressed into log 211 / log x while 152 base 8 can be expressed int o log 152 over log 8. In this case,
log 211 / log x = log 152 / log 8log x = 0.962x = 10^0.962 = 9.1632
7 0
2 years ago
Universal Containers has implemented a strict software architecture for their custom Apex code. One of the requirements is that
maxonik [38]

Answer:

The required coding for the architect to meet these requirement has been described below.

Explanation:

The following ways will help the architecture to meet the requirement.

Create a reusable SOQLQueries class; specify “With Sharing” on the methods that require user context and “Without Sharing” on the methods requiring system context.

Create a SystemSOQLQueries class and a UserSOQLQueries class; set the “With Sharing” keyword on the UserSOQLQueries class and “Without Sharing” on the SystemSOQLQueries class.

6 0
2 years ago
Sarah has entered data about football players from team A and team B in a worksheet. She enters names of players from team A wit
deff fn [24]
I believe the answer is freeze pane view

7 0
2 years ago
Read 2 more answers
A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, A3 contains 7. You enter in cell A4 the followi
Mumz [18]
<h2>Answer: B</h2>

Explanation:

The value the play displayed in Cell A4 is 12 because the value in Cell A1 is 10. Since the equation for Cell A4 is A1+2, you replace 10 with Cell A1 to get 10+2. When you add 10 and 2 together, you get your answer of 12.

7 0
2 years ago
Other questions:
  • What is an icon or animation used to represent a participant in an internet chat referred as?
    7·2 answers
  • Which sources could provide reliable evidence for your claim? Check all that apply. a step-by-step guide listed at www.gettingto
    9·2 answers
  • If there are three classes, Shape, Circle and Square, what is the most likely relationship among them?
    15·1 answer
  • In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that ma
    12·1 answer
  • Ishmael would like to capture a selected portion of his screen and then capture actions he preforms on that selected portion. Wh
    7·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • 7. Which of these statements is true? Agile is a programming language MySQL is a database HTML stands for "Hypertext Markup Link
    15·1 answer
  • Write a program to read-in a sequence of integers from the keyboard using scanf(). Your program will determine (a) the largest i
    8·1 answer
  • There are two cons to an OLTP database. Which of the following are a solution of these cons?​
    9·1 answer
  • Exercise 3.6.9: 24 vs. "24"5 points
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!