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
Why Elastic Modulus is important and on what it depends?
Bad White [126]

Answer:

The Young's Modulus of a material is a fundamental property of every material that cannot be changed. It is dependent upon temperature and pressure however. The Young's Modulus (or Elastic Modulus) is in essence the stiffness of a material. In other words, it is how easily it is bended or stretched.

Explanation:

Have a great day

5 0
3 years ago
can you translate this me gusta el queso :sorry i would have put 300 points buut i used them all for my last question
Irina-Kira [14]
Translate in Spanish: lo siento, hubiera puesto 300 puntos pero los usé todos para mi última pregunta



If you meant a different language lmk
4 0
3 years ago
Two concentric helical compression springs made of steel and having the same length when loaded and when unloaded are used to su
Andrews [41]

Answer:

see explaination for all the answers and full working.

Explanation:

deflection=8P*DN/Gd^4

G(for steel)=70Gpa=70*10^9N/m^2=70KN/mm^2

for outer spring,

deflection=8*3*50^3*5/(70*9^4)=32.66mm

for inner spring

deflection=8*3*30^3*10/(70*5^4)=148.11mm

max stress=k*8*P*C/(3.14*d^2)

for outer spring

c=50/9=5.55

k=(4c-1/4c-4)+.615/c=1.2768

max stress=1.2768*8*3*5.55/(3.14*9^2=.66KN.mm^2

for inner spring

c=6

k=1.2525

max stress=2.29KN/mm^2

6 0
4 years ago
Read 2 more answers
What is the weight density of a 2.24 in diameter titanium sphere that weights 0.82 lb?
nasty-shy [4]

Answer:

0.14\ lb/in^{3}

Explanation:

Density is defined as mass ler unit volume, expressed as

\rho=\frac {m}{v}

Where m is mass, \rho is density and v is the volume. For a sphere, volume is given as

v=\frac {4\pi r^{3}}{3}

Replacing this into the formula of density then

\rho=\frac {m}{\frac {4\pi r^{3}}{3}}

Given diameter of 2.24 in then the radius is 1.12 in. Substituting 0.82 lb for m then

\rho=\frac {0.82}{\frac {4\pi 1.12^{3}}{3}}=0.13932044952427\approx 0.14 lb/in^{3}

4 0
4 years ago
What are the four stages of BIM?
emmasim [6.3K]

Answer:A few short years ago, the use of building information modeling (BIM) was largely the domain of only the most sophisticated, forward-thinking and, some would say, well-financed project teams. Today, BIM has moved further into the mainstream and is being touted as a “transformative evolution” in the industry. For all the buzz, one thing is clear: Not all BIM is created equal. An early BIM adopter, DPR has always viewed technology as one key piece of a much larger puzzle when it comes to extracting the greatest cost savings and building the most value into a pro

Explanation:i hop this helps

3 0
3 years ago
Other questions:
  • When choosing building-construction materials, what kinds of materials would you choose, all other things being equal?
    6·1 answer
  • A 15 Watt desk-type fluorescent lamp has an effective resistance of 200 ohms when operating (note: the 15 Watts is only associat
    13·1 answer
  • Find the compressibility factor Z for oxygen at 3 MPa and 160 K.
    9·1 answer
  • Paragraph summary on airplane history
    8·1 answer
  • Light created high energy holes pass through the external circuits. (a)-True(T) (b)- false(F)
    13·1 answer
  • Realize the function f(a, b, c, d, e) = Σ m(6, 7, 9, 11, 12, 13, 16, 17, 18, 20, 21, 23, 25, 28)using a 16-to-1 MUX with control
    13·1 answer
  • The transistor is biased with a constant current source ???? = 1mA and β = 100. a) Neglecting the early effect, find the dc volt
    5·1 answer
  • A questiom for the big carb himself no cap
    7·1 answer
  • The skills and content of several subject areas were combined to form a new field known as a meta.........
    7·2 answers
  • What is a chipping hammer used for? <br><br> State three things.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!