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
vaieri [72.5K]
3 years ago
14

Help with some questions. Thank you!

Computers and Technology
1 answer:
Oksana_A [137]3 years ago
3 0

Answer:

1. E: II and III only

2. A: (int)(Math.random() * (upper − lower) ) + lower

3. A: The value of answer is N

4. E: while( !(userGuess == secretNumber) && numGuesses <= 15 )

5. C: 21

Explanation:

1. Which of the following is equivalent to while(userGuess != secretNumber)?

I. while( userGuess < secretNumber && userGuess > secretNumber)  

NO - This will test until the userGuess is smaller AND greater than the secretNumber, at the same time... so that condition will never be true.

II. while( userGuess < secretNumber || userGuess > secretNumber)

YES - This will test the value of userGuess and see if it's smaller OR greater than secetNumber.  So, it will loop until the user guesses right.

III. while( !(userGuess == secretNumber) )

YES, this will negate the match with the secretNumber.  In order words, if it's not a match, it will return true... so the loop will run until it finds a false condition (a match).

As you can see, only II and III are valid.

2.  If the lower limit were inclusive and the upper limit exclusive, which expression would properly generate values for the secret number?

A: (int)(Math.random() * (upper − lower) ) + lower

Since the lower limit is INCLUSIVE, we mustn't add one to the lower limit.  Also, the Math.random() function returns a value that matches our needs; it returns a value between [0,1[ (meaning the 0 is included, but not the 1).

Assuming the (int) caster does return only the integer portion doing a round down of the result, we'll be perfect.

3. What conclusion can be made about the state of the program when the while loop terminates?

while(!answer.equals( "N"))

{.....

A: The value of answer is N

The condition in the loops reads as "While the negation of the answer being 'N', loop".  If the answer equals 'N' then the method should return true... which will be negated by the '!' operator, causing the condition to be false. Thus we know that if the loop ends, the value of answer contains 'N', any other value will keep the loop going.

4. 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?

E: while( !(userGuess == secretNumber) && numGuesses <= 15 )

This modified condition will first test to see if the user has guessed the secretNumber (if he has, the first sub-parenthesis will be true... so the left side of the && operator will be false due to the negation operator.  The right side of the && operator will check to see how many tries have been attempted. Since the counter starts at 1, it needs to go up to 15 inclusively... so the <= is the right comparison operator.

5. After execution of the following code segment, what will be displayed?

int x = 1;

while(x < 18)

{

x += 5;

}

System.out.println(x);

C: 21

The x variable is initialized with 1... then enters the loop, in which it is incremented by 5 at each passage.

So after first passage, x = 6

After second passage, x = 11

After third passage, x = 16

After fourth passage, x = 21

Cannot enter the loop again because 21 > 18.

So, it will print out the value of 21.

You might be interested in
Landing pages in a foreign language should never be rated fully meets?
PilotLPTM [1.2K]

Answer:

if the landing page provides all kind information of information as to that site people usually like it or will most likely enjoy it

BRAINLIEST?????

Explanation:

3 0
2 years ago
A security risk to email is​ __________, which are fraudulent messages that prompt unwary users to reveal sensitive information
d1i1m1o1n [39]

Answer:

Option C is the correct answer for the above question.

Explanation:

Pishing is a type of attack which is used by the attacker to access the secured information from the system. It is used by the third person assuming for the system that he is the right use of the system and can access the information of the system.

The above question asked about the attack which can access the information to assume that he is the right user and give accessed to the network to been hacked. So the answer is phishing which is described above. Hence option C is the correct while the other is not because:-

  • Option A states about direct mail which is not a type of attack.
  • Option B states about instant messaging which is also not a type of attack.
  • Option D states about spam which is used to send the spam messages.
  • Option 'E' states about the mass mail which is used to send the lots of spam mail.
5 0
3 years ago
Which field uses computer programs to automate tasks so that they can be performed better than by humans ?
rewona [7]

Answer:

ran out of comments

Explanation:  :)

5 0
2 years ago
How to download ram<br> my computer is very slow and I need more ram
AURORKA [14]

Answer:

It is not possible to download RAM onto your computer.

Explanation:

RAM (Random-Access Memory) are physical objects installed onto your computer in the form of some sort of chip. Please do not attempt to download RAM from the internet, you may end up with malicious software on your computer. The only way to get more RAM is by installing more onto your computer or by looking at guides that can explain how to free up some RAM that may already be in use by an application.

8 0
3 years ago
Read 2 more answers
A _____ describes two or more computers connected to each other.
WARRIOR [948]

Answer:

Computer network.

Since it is 2 or more computers connected together.

5 0
3 years ago
Read 2 more answers
Other questions:
  • Is anyone familiar in drawing flow charts for c++ programming
    14·1 answer
  • . _______ are the components that allow a posi-traction differential to transfer power from one drive wheel to another.
    10·1 answer
  • What are options in the Advanced tab in the Share Workbook dialog box? Check all that apply
    14·2 answers
  • A design tool helps you plan, evaluate, and explain your ideas to create a product. Some examples of design tools are outlines,
    10·2 answers
  • You need to subnet a network that has 5 subnets, each with at least 16 hosts. Which classful subnet mask would you use?A. 255.25
    12·1 answer
  • ¿Que es la energía? (una sola respuesta es la correcta)
    11·1 answer
  • When you sign in to your Microsoft account with another Windows device, your settings will appear very differently than they do
    7·1 answer
  • What is the best low end pc recording software​
    10·2 answers
  • Which of the following statements about ip addresses is true?
    5·1 answer
  • Years ago when working a helpdesk, the most common question asked, almost daily, was about resetting passwords. What type of kno
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!