answer.
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
Refrigerant-134a enters a diffuser steadily as saturated vapor at 600 kPa with a velocity of 160 m/s, and it leaves at 700 kPa a
Zina [86]

Answer:

a) V_2 = 82.1 m/s

b) m = 0.298 Kg/s

Explanation:

from A-11 to A-13 we have the following data

P_1 = 600 kpa

V_1 = 0.033925 m^3/kg

h_1 = 262.52 kJ/kg

P_2 = 700 kpa

V_2 = 0.0313 m^3/kg

T_2 = 40°C = 313K

h_2 = 278.66 kJ/kg

Now, from the conversation of mass,

A_2*V_2/u_2 = A_1*V_1/u_1

V_2 = A_1/A_2*u_2/u_1*V_1

V_2 = A_1/1.8*A_1 * 0.0313 /0.033925*160

V_2 = 82.1 m/s

now from the energy balance equation

E_in = E_out

Q_in + m(h_1 + V_1^2/2) =  m(h_2 + V_2^2/2)

m = 0.298 Kg/s

4 0
2 years ago
Read 2 more answers
2An oil pump is drawing 44 kW of electric power while pumping oil withrho=860kg/m3at a rate of 0.1m3/s.The inlet and outlet diam
Natasha2012 [34]

Answer:

\eta = 91.7%

Explanation:

Determine the initial velocity

v_1 = \frac{\dot v}{A_1}

    = \frac{0.1}{\pi}{4} 0.08^2

     = 19.89 m/s

final velocity

v_2 =\frac{\dot v}{A_2}

      = \frac{0.1}{\frac{\pi}{4} 0.12^2}

      =8.84 m/s

total mechanical energy is given as

E_{mech} = \dot m (P_2v_2 -P_1v_1) + \dot m \frac{v_2^2 - v_1^2}{2}

\dot v = \dot m v                       ( v =v_1 =v_2)

E_{mech} = \dot mv (P_2 -P_1) + \dot m \frac{v_2^2 - v_1^2}{2}

                = mv\Delta P + \dot m  \frac{v_2^2 -v_1^2}{2}

                 = \dot v \Delta P  + \dot v \rho \frac{v_2^2 -v_1^2}{2}

              = 0.1\times 500 + 0.1\times 860\frac{8.84^2 -19.89^2}{2}\times \frac{1}{1000}

E_{mech} = 36.34 W

Shaft power

W = \eta_[motar} W_{elec}

    =0.9\times 44 =39.6

mechanical efficiency

\eta{pump} =\frac{ E_{mech}}{W}

=\frac{36.34}{39.6} = 0.917  = 91.7%

8 0
2 years ago
The best approach to keeping your car in safe working order is to
Soloha48 [4]

Answer:

Explanation:

Your car's owner's manual will provide a maintenance schedule designed to keep your brakes in good condition. Following it is the easiest way to avoid expense repairs and the potential for catastrophic brake failure. But at the very least, you should have your brakes inspected every year.

3 0
2 years ago
Read 2 more answers
The Driver of a vehicle on a level road determined that she could increase her speed from rest to 50 mi/h in 12.8 sec and from r
Ket [755]

Answer:

maximum acceleration is  1.746 m/s²

Explanation:

given data

\frac{du}{dt} = (α) - (β) ×(u(t))  

speed = rest to 50 mi/h = 22.352 m/s

time =  12.8 sec

speed = rest to 65 mi/h = 29.05 m/s

time =  19.8 sec

solution

we get here maximum acceleration of vehicle that is

maximum acceleration = \frac{\frac{du}{dt} }{t}

maximum acceleration = \frac{v1-V2}{t}    ...............1

put here value

maximum acceleration = \frac{22.352-0}{12.8}

maximum acceleration = 1.746 m/s²

and for another vehicle

maximum acceleration = \frac{29.05-0}{19.8}

maximum acceleration = 1.46 m/s²

so here maximum acceleration is  1.746 m/s²

6 0
2 years ago
Ethane (C2H6) is burned at atmospheric pressure with a stoichiometric amount of air as the oxidizer. Determine the heat rejected
Amanda [17]

Answer:

heat rejected =-1427820 KJ/mol of C_{2} H_{6}

Explanation:

Fuel ethane C_{2} H_{6}

Burning Temperature = T = 25^{0}

Pressure = P = 1 atm

The stiochiometric equation for this reaction is

C_{2} H_{6} +a_{th} (O_{2} +3.76N_{2}) >>>> 2CO_{2} + 3H_{2}O+3.76a_{th}N_{2}

The enthalpy of the reaction is given as

hc=H_{product} +H_{react}

= \Sigma N_{p} h^{0} _{f.p} -\Sigma N_{r} h^{0} _{f.r}

=\Sigma N_{p} h^{0} _{f.p}-\Sigma N_{r} h^{0} _{f.r}

=(Nh^{0} _{f} )_{CO_{2} }+(Nh^{0} _{f} )_{H_{2}O }-(Nh^{0} _{f} )_{C_{2} }H_{6}

Where

N = number of poles

h^{0} _{f} = enthalpy of formation at the standard reference stateFrom the enthalpy of formation tables  at 25 degrees  and 1 atmTaking enathalpy of formation of [tex]CO_{2} = -393520 KJ/mol

Taking enathalpy of formation of H_{2}O = -241820 KJ/mol

Taking enathalpy of formation of C_{2} H_{6} = -84680 KJ/mol

=(Nh^{0} _{f} )_{CO_{2} }+(Nh^{0} _{f} )_{H_{2}O }-(Nh^{0} _{f} )_{C_{2} }H_{6}

by putting values

hc=(2\times-393520)+(3\times-241820)-(1\times-84680 )\\

hc=-1427820 KJ/mol of C_{2} H_{6}

heat rejected = heat of enthalpy of formation

heat rejected =-1427820 KJ/mol of C_{2} H_{6}

7 0
2 years ago
Other questions:
  • Consider insulation on a circular pipe For the same thickness and type of insulation, the thermal resistance of the insulation i
    8·1 answer
  • An exercise room has six weight-lifting machines that have no motors and seven treadmills, each equipped with a 2.5-hp (shaft ou
    13·1 answer
  • Air in a 10 ft3 cylinder is initially at a pressure of 10 atm and a temperature of 330 K. The cylinder is to be emptied by openi
    10·2 answers
  • Let Deterministic Quicksort be the non-randomized Quicksort which takes the first element as a pivot, using the partition routin
    13·1 answer
  • Use the predicate specifications(x, y): x beats yF (x): x is an (American) football teamQ(x, y): x is quarterback of yL(x,y): x
    13·1 answer
  • Refrigerant-134a enters the coils of the evaporator of a refrigeration system as a saturated liquid–vapor mixture at a pressure
    5·1 answer
  • Water (cp = 4180 J/kg·°C) enters the 2.5 cm internal diameter tube of a double-pipe counter-flow heat exchanger at 17°C at a rat
    7·1 answer
  • What is the component called that usually has a dual-voltage selector switch and has cables that connect to the motherboard and
    15·1 answer
  • Air ows steadily in a thermally insulated pipe with a constant diameter of 6.35 cm, and an average friction factor of 0.005. At
    5·1 answer
  • Technician A that shielding gas nozzles may have different shapes. Technician B says that gelding gas nozzles is attached to the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!