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
soldi70 [24.7K]
3 years ago
6

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 = len1 + len2 + len3
int minLength = (int) (total + 0.5)
System. out. print(minLength)
Which of the following best describes the behavior of the code segment?
A. The code segment works as intended for all non-negative values of len1, len2, and len3.
B. 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.
C. The code segment does not work as intended for some values of len1, len2, and len3. It could be corrected by casting len1, len2, and len3 to int before adding them together and assigning the sum to minLength.
D. The code segment does not work as intended for some values of len1, 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.
E. The code segment does not work as intended for any values of len1, len2, and len3. It returns the sum of 0.5 and the three lengths for all values of len1, len2, and len3.
Computers and Technology
1 answer:
Lynna [10]3 years ago
5 0

Answer:

The answer is "option B".

Explanation:

In the given code, four double variable "len1, len2, len3, and total" is declared, in which the first three variables accept some value, and in the total variable, we add those variable. In the next step, an integer variable minLength is defined, which converts the decimal value to an integer and adds the value that is "0.5". In this section, the code uses as an intended purpose but only if the total of 3 lengths is equivalent to or larger then 0.5, and wrong choices can be described as follows:

  • In option A, It accepts the negative value, that's why it is wrong.
  • Option C, Option D, and Option E all were wrong because the code segment is work as intended.
You might be interested in
network consisting of computers and other devices that are eithrr fully or partially connected to each other
tekilochka [14]

The answer is a Mesh topology. This method connects every device to each other device in the network. A wired full-mesh topology is not as common as it is impractical and highly expensive. A partial mesh topology offers redundancy if one of the connections goes down and usually uses a connecting medium such as a router to eliminate cables and expensive PCI NIC's.

8 0
3 years ago
What number is needed to complete the pattern 66, 73, 13, 21, 52,_, 10, 20?
Lilit [14]
66,73 73-66=7
13,21 21-13=8
10,20 20-10=10

the missing no. is 9 so
52+9=61.

the pattern is
66,73,13,21,52,61,10,20





8 0
3 years ago
Can you give me a long list of kid's cartoons
notka56 [123]
Gravity Falls
Adventure Time 
SpongeBob SquarePants,
Cailou 
Bubble Guppies
Dora
Teletubbies
4 0
3 years ago
Read 2 more answers
How to make a conversation program in java
Talja [164]

Answer:

Creating a Chat Server Using Java

Introduction: Creating a Chat Server Using Java. ...

Step 1: Setup a ServerSocket in the Server Class. ...

Step 2: Create a Socket in the Login Class. ...

Step 3: Create a Loop to Continuously Accept Clients. ...

Step 4: Create the Client Threads. ...

Step 5: Create the Server Thread. ...

Step 6: Make the Client Thread Send and Receive Data.

4 0
3 years ago
In the library 6 students are working on math. of those 6 students 2/3 of them are working on fractions. how many students are w
zmey [24]
Explanation:
The word "of" in a fraction word problem USUALLY means to multiply. So we multiply 6 x 2/3

6 2 12
- x - = - = 4
1 3 3
6 0
3 years ago
Other questions:
  • Navigational signs on the highway are often which colors?
    10·2 answers
  • What is the recommended size for bulleted text? 12–22 24–40 44–66 54–80
    10·1 answer
  • Zoom Vacuum, a family-owned manufacturer of high-end vacuums, has grown exponentially over the last few years. However, the comp
    11·1 answer
  • Describe the concepts of Defense in Depth and Detection in Depth. Compare and contrast. What's different? What's similar?
    9·1 answer
  • Computers heat resistant materials breathing systems for fire fighters food-growing technologies improvements in all of the item
    14·1 answer
  • What are three ways to call attention to the text on a web page?
    6·2 answers
  • Write a script that will read from a file x and y data points in thefollowing format:
    9·1 answer
  • If you could design your own home, what kinds of labor-saving computer network or data communications devices would you incorpor
    9·1 answer
  • Write 4 types of viruses , explain them briefly.
    7·1 answer
  • Which components exist in the contextual tab for tables called Design? Check all that apply.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!