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
ohaa [14]
2 years ago
8

Consider the following incomplete code segment, which is intended to print the sum of the digits in num. For example, when num i

s 12345, the code segment should print 15, which represents the sum 1 + 2 + 3 + 4 + 5.
int num = 12345;

int sum = 0;

/* missing loop header */

{

sum += num % 10;

num /= 10;

}

System.out.println(sum);

Which of the following should replace /* missing loop header */ so that the code segment will work as intended?

while (num > 0)

A

while (num >= 0)

B

while (num > 1)

C

while (num > 2)

D

while (num > sum)

E

Engineering
1 answer:
ValentinkaMS [17]2 years ago
6 0

Answer:

A) while (num >= 0)

Explanation:

To understand why we need to focus on the module and division operation inside the loop. num % 10 divide the number by ten and take its remainder to then add this remainder to sum, the important here is that we are adding up the number in reverse order and wee need to repeat this process until we get the first number (1%10 = 1), therefore, num need to be one to compute the last operation.

A) this is the correct option because num = 1 > 0 and the last operation will be performed, and after the last operation, num = 1 will be divided by 10 resulting in 0 and 0 is not greater than 0, therefore, the cycle end and the result will be printed.

B) This can not be the option because this way the program will never ends -> 0%10 = 0 and num = 0/10 = 0

C) This can not be the option because num = 1 > 1 will produce an early end of the loop printing an incomplete result

D) The same problem than C

E) There is a point, before the operations finish, where sum > num, this will produce an early end of the loop, printing an incomplete result

You might be interested in
How is a disc brake system different from a drum brake system? Short answer
ddd [48]

Answer:

Disc brake system use a slim rotor and small caliper to halt wheel movement but a drum brake system allow heat to build up inside the drum during heavy braking .

6 0
2 years ago
Read 2 more answers
A student engineer is given a summer job to find the drag force on a new unmaned aerial vehicle that travels at a cruising speed
yan [13]

Answer:

b. 1232.08 km/hr

c. 1.02 kn

Explanation:

a) For dynamic similar conditions, the non-dimensional terms R/ρ V2 L2 and ρVL/ μ should be same for both prototype and its model. For these non-dimensional terms , R is drag force, V is velocity in m/s, μ is dynamic viscosity, ρ is density and L is length parameter.

See attachment for the remaining.

3 0
3 years ago
When replacing a timing belt, many experts and vehicle manufacturers recommend that all of the following should be replaced exce
lora16 [44]

Answer:

Correct Answer:

A. water pump

Explanation:

<em>Timing belt in a vehicle helps to ensure that crankshaft, pistons and valves operate together in proper sequence.</em> Timing belts are lighter, quieter and more efficient than chains that was previously used in vehicles.

<em>Most car manufacturers recommended that, when replacing timing belt, tension assembly, water pump, camshaft oil seal should also be replaced with it at same time. </em>

7 0
3 years ago
Use the scoring system described to calculate the alignment score for These are two lines of 14 letters aligned with each other.
PtichkaEL [24]

Answer:

do good

Explanation:

get that money

7 0
3 years ago
Fully developed conditions are known to exist for water flowing through a 25-mm-diameter tube at 0.01 kg/s and 27 C. What is the
Irina18 [472]

Answer:

0.0406 m/s

Explanation:

Given:

Diameter of the tube, D = 25 mm = 0.025 m

cross-sectional area of the tube = (π/4)D² = (π/4)(0.025)² = 4.9 × 10⁻⁴ m²

Mass flow rate = 0.01 kg/s

Now,

the mass flow rate is given as:

mass flow rate = ρAV

where,

ρ is the density of the water = 1000 kg/m³

A is the area of cross-section of the pipe

V is the average velocity through the pipe

thus,

0.01 = 1000 × 4.9 × 10⁻⁴ × V

or

V = 0.0203 m/s

also,

Reynold's number, Re = \frac{VD}{\nu}

where,

ν is the kinematic viscosity of the water = 0.833 × 10⁻⁶ m²/s

thus,

Re = \frac{0.0203\times0.025}{0.833\times10^{-6}}

or

Re = 611.39 < 2000

thus,

the flow is laminar

hence,

the maximum velocity =  2 × average velocity = 2 × 0.0203 m/s

or

maximum velocity = 0.0406 m/s

5 0
2 years ago
Other questions:
  • A power company desires to use groundwater from a hot spring to power a heat engine. If the groundwater is at 95 deg C and the a
    7·1 answer
  • Which of the following is an activity of daily living? jogging cleaning weightlifting all of the above
    13·1 answer
  • A baseband signal with a bandwidth of 100 kHz and an amplitude range of±1 V is to be transmitted through a channel which is cons
    8·2 answers
  • Burn in hell i watched your stupid video and i still could not get the answer
    14·1 answer
  • Write a program that asks the user to input a vector of integers of arbitrary length. Then, using a for-end loop the program exa
    13·1 answer
  • Explain why Chloe's design needs to be redone in the following scenario, and recommend the techniques she needs to include in he
    15·2 answers
  • Work to be performed can come from the work package level of the work breakdown structure as well as other sources. Which of the
    11·1 answer
  • Drivers education :Anything that draws your mind off driving is
    9·1 answer
  • When bending metal, the material on the outside of the curve stretches while the material on the inside of the curve compresses.
    14·1 answer
  • The thrust angle is checked by referencing
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!