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
patriot [66]
3 years ago
13

A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the following code segment is intended t

o 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.
Computers and Technology
2 answers:
Nonamiya [84]3 years ago
7 0

Answer:

The correct option is option 3 which is 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.

Explanation:

As the variable minLength is defined as an integer thus the value is being truncated although the value of 0.5 is being added however if the decimal portion of the length is less than 0.5, the portion is truncated.

VikaD [51]3 years ago
5 0

Answer:

Answer is option 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. Therefore,

Refer below for the explanation.

Explanation:

As the integer minlength that will result as final output illustrates that the integer of three ropes added 0.5 in the final output minlength.

You might be interested in
Suppose x and y are int variables and ch is a char variable. Consider the following input: 5 28 36 What value (if any) is assign
eimsori [14]

Answer:

x is assigned "5", y is assigned "28", and ch is assigned "$"

Explanation:

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   int x,y;

   char ch;

   x = 5;

   y = 28;

   ch = 36;

   cout<<x<<endl<<y<<endl;

   cout<<ch;

   return 0;

}

4 0
2 years ago
Choose the best technology device for the
Oxana [17]

Answer:

Desktop computer with 2 screens

Explanation:

All graphices designers need the most screen space possible

8 0
3 years ago
How does form get its power natural gas
lana [24]

Answer:

because it does

Explanation:

7 0
3 years ago
HELP! Answer to question 2?
Vesnalui [34]
One advantage of Binary Search Algorithm: 
Compared to Linear search it is much faster because linear search starts its searching right from the first value but binary searches for something by splitting the array in two again and again and again. 

One disadvantage of Binary Search Algorithm:
Have to be sorted, unlike linear search that doesn't have to be. 
4 0
3 years ago
You are having trouble closing a program. You have tried to hit the Close button, the keyboard shortcut to close the program, an
vladimir2022 [97]

Answer:

You can open the version of your computer or device from the task manager to see the running programs and close the application

Explanation:

Right-click on the Windows Start menu and choose Task Manager (another way to open it is to press the keyboard shortcut Ctrl + Alt + Delete and select it from the options that appear).

NOTE: Click here if you don't know how to display Windows 8 Start.

You will see the main Administrator window (as in the image above). Displays a list of the programs that are currently running.

Find the application or process you want to close. Click on it with the RIGHT button and choose End task. In some cases a notice appears asking you to confirm it. Read what it says to know the consequences of forcing it. Confirm if you are determined to do so.

IMPORTANT:

There are viruses, adware or other spam programs that you may not be able to close even in this way. For these cases follow this link on how to clean viruses without entering Windows.

When you're done you can exit the Task Manager window. Click here to close background applications.

Estos pasos sirven para forzar que se cierren programas que no responden en Windows 10, 8 u 8.1. Enlazan además a instrucciones para cerrar programas o aplicaciones

4 0
3 years ago
Other questions:
  • How does the use of modules provide flexibility in a structured programming design?
    14·2 answers
  • HELP NOW PLZZ/ Question: Complete the sentence with the correct response.
    11·1 answer
  • The local emergency manager has the responsibility for coordinating emergency management programs and activities. A local emerge
    7·1 answer
  • To build a user interface that contains graphical components, the components ____. must each be added to a separate panel. must
    7·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    13·1 answer
  • For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions)
    13·1 answer
  • The response from a Google Form can be seen in how many ways?
    10·1 answer
  • The Operating System is used to locate, move, and copy files.
    10·1 answer
  • A brick has a weight of 23N. The brick is flat and smooth on the side in contact with the floor having measurements ( height= 5c
    13·1 answer
  • Raul is a 13-year-old teenager interested in taking up photography as a new hobby. His dad wants to buy him a camera for his bir
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!