subject

Use the following file to answer the questions (attached below): 1.

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. Assuming numGuesses is initialized to 1, how would the while statement be modified to include an extra criterion limiting the number of guesses to 10?

A while( (userNumber != secretNumber) && numGuesses secretNumber)
II while( userGuess secretNumber)
III while( userGuess = secretNumber)

A. I only

B. II only

C. III only

D. I and II only

E. I and III only

3.

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

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

int x = 0;

while(x < 20)

{

x += 3;

}

System. out. println(x);

A. 6

B. 18

C. 20

D. 21

E. 24

4.

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

5.

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 exclusive, 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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:40
Program using c++ only on visual studio pig is a simple two player dice game, played with one die. the first player to reach or surpass 50 is the winner. each player takes a turn rolling the dice. they add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. the risk being they could lose the amount they’ve accumulated into the pot. the rules for each player’s die roll. 1. roll the dice. a. if user rolled a 1, i. the pot gets set to zero ii. the other player goes to step 1. b. a roll of 2-6 is added to the pot. 2. user can choose to hold or roll again. a. choice roll. return to step 1. b. choice hold. i. increment player score by the pot amount. ii. pot gets set to 0. iii. second player gets to roll and goes to step 1. program requirements: ● before each opponent begins β—‹ output the score for the person and the computer. β—‹ output the opponents whose turn is beginning and ask the user to hit enter to continue. ● with each dice roll. β—‹ output the die value, and amount of the round pot. β—‹ if it’s the users roll ask if they want to roll again ( r ) or hold ( h ). your program should allow r, r, h or h as valid input. if input is anything else, ask the user again until valid input is obtained. β—‹ the ai will continue playing until the round pot is 20 or more. ● once a player’s score is greater or equal to 50 then they have won, it will no longer ask if they want to keep rolling the die or not. ● once there is a winner β—‹ score totals are output along with who the winner was. user or computer β—‹ player is asked if they want to play again y or n. valid input should be y, y, or n, n. ● when a new game starts the starting roll goes to the player that did not roll last. if the user rolled last in the previous game, then the computer rolls first and vice versa. when the program first begins, the player will make the first roll of the first game. development notes : ● you will need a way to roll dice in your program. the rand() function works well, but returns an integer. if we want numbers 0 – 9 we can get the value modulus 10. ● call srand() with a value to seed it. it’s common to seed it with the current computer clock, include ctime, and then call srand(time(
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
Worth 50 points answer them bc i am not sure if i am wrong
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
You know the right answer?
Use the following file to answer the questions (attached below): 1.

Errors can be synta...
Questions
question
Mathematics, 27.02.2020 03:27
Questions on the website: 13722360