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
Which of the following is an individual’s social equals?
ozzi
Its multiple choice what did they say
4 0
4 years ago
Which of the following refers to a descriptive technique involving the systematic collection of quantitative​ information? A. Lo
Nastasia [14]

Answer:

The answer is "Option C".

Explanation:

This technique is also known as walking-sectional experimental research, which only collects information at one stage. The goal of using this strategy is to create a single point, that provides representations to the population of interest, and other choices were wrong, that can be described as follows:

  • In option A, It is wrong, because this designing technique is used to search the relationship between variables.
  • In option B, It is a form of marketing, that provides communication via telephone, that's why it is incorrect.
  • In option D, It is used in research, that's why it is not correct.
  • In option E, It is wrong, because it is used in business.
6 0
3 years ago
Above all else, be...
ch4aika [34]
B) yourself

hope this helps :)
6 0
3 years ago
Computer ForensicsThere are many differences between public-sector and private-sector computer investigations. What do you see a
elena55 [62]

Answer:

For a private computer investigation into cyber crime the private sector  should complete all its courses and must be certified by the relevant authorities and must also be an expert in the computer investigations. while

Public computer investigations has more aspects that involves non-certified personnel's

The private-sector computer investigations are used mostly on all the cyber crimes and hacking and loss of business data.while public-sector computer investigations are used on crimes like rapes, accidents and murders crimes

Explanation:

Computer forensics are used to resolve crimes like cyber crime, hacking, malfunctions and data interrupts.

Before a private computer investigations which is into cyber crime investigation can continue, the private sector  should complete all its courses and must be certified by the relevant authorities and must also be an expert in the computer investigations. while

Public computer investigations has more aspects that involves non-certified personnel's and the personnel's are not necessarily supposed to complete the courses

The private-sector computer investigations are used mostly on all the cyber crimes and hacking and loss of business data.while public-sector computer investigations are used on crimes like rapes, accidents and murders crimes

5 0
4 years ago
You can clear a log file simply by redirecting nothing into it. true or false?
nekit [7.7K]
True

cat /dev/null > fileName


------------------------------------
6 0
4 years ago
Other questions:
  • Illustrate the process of using an operating system to manipulate a computer’s desktop, files and disks.
    12·1 answer
  • What is the area of a triangle whose base is 14 m and whose height is 22 m?
    7·1 answer
  • Naseer has inserted an image into his document but needs the image to appear on its own line.
    5·2 answers
  • What function is the responsibility of the network layer?
    10·1 answer
  • Plssss helpppp!!<br><br>Thanks
    11·2 answers
  • What two windows tools can you use to know how much ram is installed on your system?
    10·1 answer
  • Liam and his friend are regular viewers of their favorite podcast about photography techniques. What is the best way for them to
    15·1 answer
  • Let f be the following function: int f(char *s, char *t){char *p1, *p2;for(p1 = s, p2 = t; *p1 != ‘\0’&amp;&amp; *p2 != ‘\0’; p1
    6·1 answer
  • If you’d like to have multiple italicized words in your document, how would you change the font of each of these words
    13·1 answer
  • Given the tables PRODUCT (ProductID. Description. Cost) SUPPLIER (Supplier D. ContactName, Phone Number) as shown in the figure
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!