Computers and Technology

Question 1 Errors can be syntax errors or logic errors (the code works, but not as intended).

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?

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

Question 2
Errors can be syntax errors or logic errors (the code works, but not as intended).

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

while(answer. equals("N"))
{
// code not shown
}

A) The value of answer is N
B) The value of answer is n or N
C) The value of answer is not N
D) The value of answer is Y
E) Nothing can be determined

Question 3
Errors can be syntax errors or logic errors (the code works, but not as intended).

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

I) while( userGuess < secretNumber && userGuess > secretNumber)
II) while( userGuess < secretNumber || userGuess > secretNumber)
III) while( !(userGuess == secretNumber) )

I only
II only
III only
I and III only
II and III only

Question 4
Errors can be syntax errors or logic errors (the code works, but not as intended).

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?

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)

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 19:30, davisparker5269
Write a function processpeople() that takes the name of a file as a parameter. each line of the file corresponds to information about a person. in particular a line contains either a name (in the form lastname, firstname with no spaces in it) or a name (lastname, firstname) and a year. the function will process the file, creating a person object for each line in the file. the function will print information about each line as it processes it, as well as appending the new person object into a list. make sure to use person methods to display information rather than recreating the work you did for the first problem. once the entire file has been processed, the function returns the list of person objects created from the file. if the file is empty, the function should return an empty list. if the input file cannot be opened, the function should print a message to that effect and then return an empty list. the following shows what would be displayed for two example files which have been provided in the link. the file none. txt does not exist. note that your function must work on an arbitrary file that consists of valid lines. you cannot assume anything about the file except that it contains lines that have the format described above.
Answers: 2
image
Computers and Technology, 22.06.2019 01:00, labrandonanderson00
Ap practice - performance task response the ap create performance task asks you to write about an abstraction that you developed and wrote into your code. most of the time that means identifying a function or procedure you wrote to "manage complexity" in your program. here is the actual prompt from the create performance task: 2d. capture and paste a program code segment that contains an abstraction you developed individually on your own (marked with a rectangle). this abstraction must integrate mathematical and logical concepts. explain how your abstraction manage the complexity of your program. (must not exceed 200 words) below is a segment of code from an "under the sea" program with a rectangle drawn around a portion of the code identifying an abstraction. imagine that you wrote this and are composing an ap response about how this abstraction manages complexity. (note: ignore the requirement that the abstraction integrate "mathematical and logical concepts" for this practice response. just write about managing complexity). explain how the abstraction marked with the rectangle in the code above manage complexity of this program. write your response here submit
Answers: 2
image
Computers and Technology, 22.06.2019 10:30, ghazanfarwaheed7967
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
image
Computers and Technology, 23.06.2019 00:00, brooklyn4932
What engine component is shown in the above figure?
Answers: 1
Do you know the correct answer?
Question 1 Errors can be syntax errors or logic errors (the code works, but not as intended).
...

Questions in other subjects:

Konu
Mathematics, 10.03.2020 01:16