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
When you use a while loop to compute the product of several values, you should initialize the variables holding the product to _
Allushta [10]

Answer:

b.1

Explanation:

When we are using while loop to compute the product of several values we need to initialize the value holding the product to 1 because when we multiply something with 1 it will give the same number.

If we initialize it with 0 the product will come out to be 0 because  anything multiplied by 0 is 0.

we cannot initialize it with NULL because it is not a pointer.

We need to initialize the number since it contains garbage values so it will give product with that value.

3 0
2 years ago
Michael has increased the contrast of the given picture. Which feature or menu option of a word processing program did he use?
shepuryov [24]

ANSWER

A. Format  

Hope this helps!!!

8 0
2 years ago
Read 2 more answers
A domain's ____ settings must be configured correctly so that the mail transfer agent (mta) can establish a connection with a re
Oksi-84 [34.3K]

i think its firewall. Because the firewall can block protocols are are not allowed by an administrator. especially over a remote connection

5 0
2 years ago
Write a C# program named ProjectedRaises that includes a named constant representing next year’s anticipated 4 percent raise for
nydimaria [60]

Answer:

using System;

class ProjectedRaises {

 static void Main() {

     const float raise = 0.04f;

     double salary1 = 0.0f,salary2 = 0.0f,salary3 = 0.0f;

Console.WriteLine("Current salary for each employee: ");

     salary1 = Single.Parse(Console.ReadLine());

     salary2 = Single.Parse(Console.ReadLine());

     salary3 = Single.Parse(Console.ReadLine());

     salary1 = salary1 + raise * salary1;

     salary2 = salary2 + raise * salary2;

     salary3 = salary3 + raise * salary3;

     Console.WriteLine("Next year salary for the employees are: ");

     Console.WriteLine(Math.Round(salary1));

     Console.WriteLine(Math.Round(salary2));

     Console.WriteLine(Math.Round(salary3));

}

}

Explanation:

This declares and initializes variable raise as a float constant

     const float raise = 0.04f;

This declares the salary of each employee as double

     double salary1 = 0.0f,salary2 = 0.0f,salary3 = 0.0f;

This prompts the user for the salaries of the employee

Console.WriteLine("Current salary for each employee: ");

The next three lines get the salary of the employees

<em>      salary1 = Single.Parse(Console.ReadLine());</em>

<em>      salary2 = Single.Parse(Console.ReadLine()); </em>

<em>      salary3 = Single.Parse(Console.ReadLine()); </em>

The next three lines calculate the new salaries of the employees

<em>      salary1 = salary1 + raise * salary1;</em>

<em>      salary2 = salary2 + raise * salary2;</em>

<em>      salary3 = salary3 + raise * salary3;</em>

This prints the header

     Console.WriteLine("Next year salary for the employees are: ");

The next three lines print the new salaries of the employees

     Console.WriteLine(Math.Round(salary1));

     Console.WriteLine(Math.Round(salary2));

     Console.WriteLine(Math.Round(salary3));

7 0
2 years ago
During college jesse spent four semesters studying abroad in other parts of the world how could jesses time abroad benefit his e
Yuliya22 [10]

Information technology is more global than other fields. Jesse's diverse college background could help him remain culturally sensitive during communications with collaborators from other parts of the world.

4 0
2 years ago
Read 2 more answers
Other questions:
  • In three to five sentences, describe whether or not files should be deleted from your computer.
    13·2 answers
  • Using evidence to dispel myths or false beliefs is one way to move closer to evidence-based practice. Please select the best ans
    13·2 answers
  • Why can't you use Friedman's attack on block ciphers?
    12·1 answer
  • Write a program to determine all pairs of positive integers, (a, b), such that a &lt; b &lt; 1000 and [a2 + b2 + 1)/(ab) is an i
    13·1 answer
  • PC’s &amp; More has shifted to sales and service of laptops and PCs, where it has the potential to triple the number of its cust
    14·1 answer
  • Select which type of computer you would like to begin building, based on the needs of your new job: Frequent travel Maintaining
    7·1 answer
  • JAVA
    7·1 answer
  • Which of the following is true about sorting functions?
    14·1 answer
  • Which of the following is true of how the Internet has responded to the increasing number of devices now using the network? a) T
    12·2 answers
  • Write a complete Java program that: Prompts an employee to enter the number of hours that they have worked in a given week and s
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!