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]
3 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]3 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
A 12-kN tensile load will be applied to a 50-m length of steel wire with E = 200 GPa. Determine the smallest diameter wire that
Ira Lisetskai [31]

Answer:

The smallest wire diameter that can be used is 1 cm

Explanation:

First, we find the smallest diameter using the criterion of maximum normal stress:

Max. Stress = 150 x 10^6 Pa = F/A

150 x 10^6 Pa = 12000 N/(πd²/4)

d² = (12000 N)(4)/(150 x 10^6 Pa)(π)

d = √1.0185 x 10^-4 m²

d = 0.010 m = 1 cm

Now, we find the smallest diameter using the criterion of maximum strain:

Max. Strain = Max. Change in Length/Original Length = 0.025 m/50 m

Max. Strain = 5 x 10^-4 mm/mm

Now,

Max. Strain = Stress/E = (F/A)/E = F/AE

using values:

5 x 10^-4 mm/mm = (12000 N)/(200 x 10^9 Pa)(πd²/4)

d =√(12000 N)(4)/(5 x 0^-4)(200 x 10^9 Pa)(π)

d = 0.012 m = 1.2 cm

Now, by comparison in both cases it can be noted that the smallest value of the diameter is <u>1 cm</u>, which is limited by maximum stress.

7 0
3 years ago
If a ball is dropped from a height​ (H) its velocity will increase until it hits the ground​ (assuming that aerodynamic drag due
enot [183]

Answer

Explanation:

so the velocity is 39 feet per sec so the impact is 720 cm from the ground

take 720 * 39 sq

4 0
4 years ago
Charging the system is being discussed. Technician A says that the refrigerant must be weighed (or metered) to obtain a proper c
andrey2020 [161]

Charging the system is being discussed. Technician A is correct and Technician B is incorrect because overcharging can cause the system to reduce it capacity, but it does not reduce its cooling efficiency.

<h3>What is a coolant?</h3>

The coolants are the liquid that are present in machines to prevent the  heating of the system or machines. Because machine and cars run they generate lots of heat that why there are coolants present.

Thus, the correct option is Technician A.

Learn more about coolant

brainly.com/question/11912897

#SPJ1

7 0
2 years ago
This elementary problem begins to explore propagation delayand transmission delay, two central concepts in data networking. Cons
telo118 [61]

Explanation:

(a)

Here, distance between hosts A and B is m meters and, propagation speed along the link is s meter/sec

Hence, propagation delay, d_{prop} = m/sec (s)

(b)

Here, size of the packet is L bits

And the transmission rate of the link is R bps

Hence, the transmission time of the packet,  d_{trans} = L/R

(c)

As we know, end-to-end delay or total no delay,

\mathrm{d}_{\text {nodal }}=\mathrm{d}_{\text {proc }}+\mathrm{d}_{\text {quar }}+d_{\max }+d_{\text {prop }}

Here,  $\mathrm{d}_{\text {rroc }}$ and $\mathrm{d}_{\text {quat }}$ \\Hence, $\mathrm{d}_{\text {rodal }}=\mathrm{d}_{\text {trass }}+\mathrm{d}_{\text {prop }}$ \\We know, $\mathrm{d}_{\text {trax }}=\mathrm{L} / \mathrm{R}$ sec and $\mathrm{d}_{\text {vapp }}=\mathrm{m} / \mathrm{s}$ sec\text { Hence, } {d_{\text {nodal }}}=\mathrm{L} / \mathrm{R}+\mathrm{m} / \mathrm{s} \text { seconds }

(d)

The expression, time time $t=d_{\text {trans }}$ means the\at time since transmission started is equal to transmission delay.

As we know, transmission delay is the time taken by host to push out the packet.

Hence, at time $t=d_{\text {trans }}$ the last bit of the packet has been pushed out or transmitted.

(e)

If \ d_{prop} >d_{trans}

Then, at time $t=d_{\text {trans }}$ the bit has been transmitted from host A, but to condition (1),  the first bit has not reached B.

(f)

If \ d_{prop}

Then, at time $t=d_{\text {trans }}$, the first bit has reached destination on B

Here,s=2.5 \times 10^{8} \mathrm{sec}

\begin{aligned}&\mathrm{L}=100 \mathrm{Bits} \text { and }\\&\mathrm{R}=28 \mathrm{kbps} \text { or } 28 \times 1000 \mathrm{bps}\end{aligned}

It's given that \ d_{prop} =d_{trans}

Hence,

        \begin{aligned}\ & \frac{L}{R}=\frac{m}{s} \\m &=s \frac{L}{R} \\&=\frac{2.5 \times 10^{8} \times 100}{28 \times 1000} \\&=892.9 \mathrm{km}\end{aligned}

5 0
3 years ago
A hollow aluminum alloy [G = 3,800 ksi] shaft having a length of 12 ft, an outside diameter of 4.50 in., and a wall thickness of
Lisa [10]

Answer:

Horse power = 167.84 hp

Explanation:

Horsepower is calculated using the formula;

P = T * w

See the attached file for the calculation

6 0
4 years ago
Other questions:
  • The difference between absolute viscosity and kinematic viscosity is a. the absolute viscosity is the mass density divided by th
    10·1 answer
  • Problem 8. Define a function gs1_error(n) that accepts as input a non-negative integer n and outputs the error of the Gauss-Seid
    7·1 answer
  • What torque specs to heads bolts need to be at for a 76 small block chevy
    9·1 answer
  • The purpose of the __________ algorithm is to enable two users to exchange a secret key securely that can then be used for subse
    8·1 answer
  • It is the responsibility of every employee to ensure that tools are used ____ and____.
    13·1 answer
  • 1. What's an object in your everyday life that has a lot of Kinetic Energy? How do you know it has a lot?
    5·1 answer
  • How can you throw a ball as hard as you can and have it come back to you, even if it doesn't
    15·1 answer
  • Are you?
    7·2 answers
  • How much profit does the fossil fuel industry make
    11·1 answer
  • A full wave bridge rectifier is used to charge a battery of 24 V and 120 W-H. If the supply voltage with 220 V is used to feed t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!