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
Pls help me thx would really help me
Assoli18 [71]

Answer:

rooster don't lay eggs tho

4 0
3 years ago
Read 2 more answers
How do you access the dark web? What are the negatives of doing this?
Inessa05 [86]
The dark web is illegal and therefore people can hack you, obtain your information (identity theft) etc.
6 0
3 years ago
The RAND() function in Excel returns a pseudo-random number between 0 and 1. If you enter this function into 1000 cells (i.e. en
Neko [114]

Answer:

To get this, filter the column with the condition "less than or equal 0.1" and check the number of returned rows at the bottom of the worksheet ( mine is 87 rows from 1000).

Explanation:

The RAND() function in Microsoft Excel is used to generate random numbers between zero and one. It can also be used to generate a range of numbers with decimal places by multiplying the stop number with the rand function  

4 0
3 years ago
Preparing for jobs that are high in demand allow you to...
quester [9]

Preparing for jobs that are high in demand allows an individual to focus their development of human capital on those careers.

Focus your development of human capital on those careers

<u>Explanation:</u>

As the demand for the job is high, there is no denying the fact that it will increase the likelihood of getting a job. It is a simple proportion, more the number of jobs, more are the chances of getting them.

Last but not least it will also allow an individual to be more attractive to employers in those fields. As an individual prepares for the job, they will acquire certain skills and knowledge that are capable of letting them being perceived as attractive.

7 0
3 years ago
Describe the positive and negative effects of Internet​
kvasek [131]

Answer:

pos-ugly

neg-gay

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What finacial behaivor will typically lead to a low credit score
    8·1 answer
  • Open Source software is:
    6·1 answer
  • To add text into a SmartArt graphic, a user will need to _____.
    14·1 answer
  • Vanessa and Marie are best friends. Vanessa tells Marie that one of their classmates has been posting nasty comments about Vanes
    10·2 answers
  • 1.Write the Qbasic program to find sum of any 10 different numbers.
    12·1 answer
  • Cliff just started working with a client who has a very disorganized AdWords account. What’s an effective way for him to begin r
    15·1 answer
  • A key tactic that is used in many attacks, but very frequently in CEO Fraud, is creating a sense of what?
    15·2 answers
  • Please help ASAP !!!
    15·1 answer
  • Write javascript code for the form that appears in the image below. you are expected to add validation to the name field, email
    10·2 answers
  • 04. Suppose a computer program needs to sort a list of student records in ascending order
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!