subject

A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the following code segment is intended to display the minimum length of rope, in feet, that must be purchased so that the rope is long enough to be cut into the three lengths. For example, for lengths of 2.8 feet, 3 feet, and 5 feet, the minimum length of rope that must be purchased is 11 feet. For these inputs, the code segment should display 11. As another example, for lengths of 1.1 feet, 3.2 feet, and 2 feet, the minimum length of rope that must be purchased is 7 feet. For these inputs, the code segment should display 7.
double len1
double len2 double len3; double total = lenl + len2 + len3; int minLength = (int) (total + 0.5); System. out. print(minLength);
Which of the following best describes the behavior of the code segment?
1. The code segment works as intended for all nonnegative values of lent, len2, and len3.
2. The code segment does not work as intended for some values of lent, len2, and len3. It could be corrected by casting lent, len2, and len3 to int before adding them together and assigning the sum to minLength. The code segment does not work as intended for any values of lent, len2, and len3. It returns the sum of 0.5 and the three lengths for all values of lent, len2, and len3. 3. The code segment works as intended but only when the sum of the three lengths is an integer or the decimal part of the sum of the three lengths is greater than or equal to 0.5. 4. The code segment does not work as intended for some values of lent, len2, and len3. It could be corrected by declaring minLength as a double and casting it to an int in the System. out. print statement.

ansver
Answers: 1

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, 22.06.2019 19:10
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
question
Computers and Technology, 23.06.2019 18:00
Freya realizes she does not have enough in her bank account to use the debit card. she decides to use a credit card instead. which questions should freya answer before using a credit card? check all that apply. can i pay at least the minimum payment each month? can i make payments on time and avoid late fees? will i have to take out a loan? how much in finance charges can i afford to pay? should i talk to a consumer credit counseling service?
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Which option completes the explanation for conflict of interest in an organization
Answers: 1
You know the right answer?
A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the followin...
Questions
question
Mathematics, 19.02.2021 18:50
question
Arts, 19.02.2021 18:50
question
Mathematics, 19.02.2021 18:50
question
Mathematics, 19.02.2021 18:50
Questions on the website: 13722367