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
Which statement describes how to insert the IF, COUNTIF, or SUM function into a cell?
Gre4nikov [31]

Answer:

B Type an = sign in the cell, followed by the name of the function and the relevant arguments.

Explanation:

always look for =

8 0
3 years ago
How does a color change if you add more gray to it
Tom [10]
Gray isn't a color to be exact it a shade or what some people call it a shadow just like black but if you add more gray to a look lets say RED it will make it kinda faddy and more darker then it was

6 0
2 years ago
What does ' array ' mean in the context of graphics programming ?
Readme [11.4K]

Answer:

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

3 0
2 years ago
In c please
Paraphin [41]

Answer:

#include <stdio.h>

#include <ctype.h>

void printHistogram(int counters[]) {

   int largest = 0;

   int row,i;

   for (i = 0; i < 26; i++) {

       if (counters[i] > largest) {

           largest = counters[i];

       }

   }

   for (row = largest; row > 0; row--) {

       for (i = 0; i < 26; i++) {

           if (counters[i] >= row) {

               putchar(254);

           }

           else {

               putchar(32);

           }

           putchar(32);

       }

       putchar('\n');

   }

   for (i = 0; i < 26; i++) {

       putchar('a' + i);

       putchar(32);

   }

}

int main() {

   int counters[26] = { 0 };

   int i;

   char c;

   FILE* f;

   fopen_s(&f, "story.txt", "r");

   while (!feof(f)) {

       c = tolower(fgetc(f));

       if (c >= 'a' && c <= 'z') {

           counters[c-'a']++;

       }

   }

   for (i = 0; i < 26; i++) {

       printf("%c was used %d times.\n", 'a'+i, counters[i]);

   }

   printf("\nHere is a histogram:\n");

   printHistogram(counters);

}

5 0
2 years ago
which feature will configuring a SOHO network in which all ports on the public untrusted network will be forwarded to one workst
Ugo [173]

Answer:

Demilitarized zone (DMZ).

Explanation:

Demilitarized zone is a kind of security assurance scheme used by network administrator to detect network breach even before it gets to the secured network.

The private LAN is protected with a firewall and a DMZ is configured to allow access by untrusted users, on another workstation, which is a duplicate of the companies private local address.

7 0
3 years ago
Other questions:
  • Philip is thinking about customizing his motorcycle. A paint job, saddlebags, and a radio would cost $600. His motorcycle is old
    15·2 answers
  • Intro to cs 3.7 edhesive g=float(input("Enter your English test grade:")) if(g&lt;=64): print("F") if (g&gt;=65 and g&lt;69): pr
    11·1 answer
  • Write a function addOne that adds 1 to its integer referenceparameter. The function returns nothing.
    11·1 answer
  • Sandy's keyboard is not inputting data into her computer which key should she press to verify it is connected to her computer...
    11·1 answer
  • Blank includes websites that encourage interaction and connection among people businesses and organizations
    14·2 answers
  • Which element of a presentation program’s interface displays the slide you are currently creating or editing?
    14·2 answers
  • Ad identifies and describes at least four ways to prevent downloading of spyware, adware, and viruses to computer
    9·1 answer
  • Someone please make a random question with an easy answer because i need one more brainliest to UPGRADE!
    7·2 answers
  • Help! Picture provided
    7·2 answers
  • Write a Pascal program that will prompt the user to enter the radius of a circle.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!