The following for loop prints the numbers 1 to 20 on one line with a space between.

for (int i = 1; i <= 20; i++)
{
System.out.print(i + " " ); // prints each value of i followed by a space on one line
}

Question

Consider the for loop example above. Assume you want to adjust the loop to print only the even values from 1 and 20. What must the loop elements - counter initialization, conditional statement, and counter modification - be set to in order to accomplish the goal.

Review all options listed below carefully. You MUST select 3 answers; one for each element/category:

Counter initialization
Conditional statement
Counter modification
a. int i = 0;
b. int i = 1;
c. int i = 2;
d. i < 20;
e. i <= 20;
f. i > 20;
g. i++;
h. i+=1-;
i. i+=2;

Answers

Answer 1

Answer:

Counter initialization: [tex]\verb!int i = 2![/tex].

Conditional statement: [tex]\verb!i <= 20![/tex].

Counter modification: [tex]\verb!i += 2![/tex].

Step-by-step explanation:

In the current Java for-loop in this question:

The counter initialization statement [tex]\verb!int i = 1![/tex] in this for-loop would initialize the counter variable to integer [tex]1[/tex]. The conditional statement [tex]\verb!i <= 20![/tex] holds as long as the counter is less than or equal to [tex]20[/tex]. Thus, the largest possible value for the counter would be [tex]20\![/tex].The counter modification statement [tex]\verb!i++![/tex] is equivalent to [tex]\verb!i += 1![/tex]. This statement would add [tex]1[/tex] to the value of the counter in each iteration.

The even integers between [tex]1[/tex] and [tex]20[/tex] includes [tex]2,\, 4,\, \dots,\, 20[/tex]. It would be necessary to add [tex]2[/tex] each time to get to the next number.

Since the list of even integers starts at [tex]2[/tex], it would be necessary to initialize the counter variable to [tex]2\![/tex] rather than [tex]1[/tex]. Thus, replace the counter initialization statement [tex]\verb!int i = 1![/tex] with [tex]\verb!int i = 2![/tex].

The maximum integer that this loop should print is still [tex]20[/tex]. Thus, the conditional statement [tex]\verb!i <= 20![/tex] does not need to be changed.

The for-loop should add [tex]2[/tex] to the counter each time to get to the next even integer. Thus, the counter modification statement [tex]\verb!i++![/tex] (or equivalently, [tex]\verb!i += 1![/tex]) should be replaced with [tex]\verb!i += 2![/tex].

Overall, the for-loop should be:

[tex]\begin{aligned}& \verb!for (int i = 2; i <= 20; i += 2) {!\\ &\quad \verb!System.out.print(i + " ");! \\ &\verb!}!\end{aligned}[/tex].


Related Questions

(Score for Question 3:
of 3 points)
3. Describe the transformation that takes
(x)=x+1 to g(x) = -x +4.
Answer:

Answers

Answer:

It's a rotation of 90 degrees - doesn't matter which way - around the intersection of the two lines

Step-by-step explanation:

Claim: it's a 90 degree rotation around the intersection of f and g.

It's easy to spot the two lines  are perpendicular. Let's assume the rotation doesn't happen at the point of intersection [tex]x_0[/tex], but slightly to the side, around let's say, [tex]x_0+\epsilon[/tex]; the new line will coincide with [tex]g(x)[/tex] if and only if [tex]\epsilon = 0[/tex], ie only the rotation happens around the intersection.

A radioactive isotope decays at the rate indicated by the exponential function A (t) =800 (1/2) ^ t/1500, where “t” is the time in years and A(t) is the amount of the isotope, in grams, remaining what is the initial mass of the isotope?
A. 200 grams
B. 900 grams
C. 800 grams
D. 400 grams

Answers

The answer is A 200 grams

Complete the missing factors

6a^2 + 11b - 35b^2 = ( 3a _______)(2a______)

please help me, thank you.​

Answers

(3a-5b)•(2a+7b)
That’s the answer

Jordan’s family exchanged 250 dollars for 5000 pesos.
Jordan bought a sweater for 550 pesos.
How much dollars is it for the cost of one peso

Answers

The number of dollars for one peso is 20 dollars.

Exchange rate is the rate at which one currency is exchanged for another currency.

In order to determine how many pesos can be exchanged for a dollar, the value of pesos would be divided by the amount of dollars exchanged.

Exchange rate = 5000 / 250 = 20 dollars

This means that 1 peso would be exchanged for 20 dollars.

A similar question was answered here: https://brainly.com/question/18236223

9000 is borrowed at 4.5% rate of interest pa for 2 years. Find the amount to be paid at the end of the second year? pleasee need answer fastt

Answers

Answer:9810

Step-by-step explanation:

S.I. = PRT/100

9000 ×4.5 × 2/100

S.I = 810

Amount after 2 years = 9000+810

= 9810

Tom finished 2/4 , of his math homework on the school bus. What percent did he finish on the
bus?

Answers

Answer:

50

Step-by-step explanation:

Answer:

50%

Step-by-step explanation:

2/4 = 1/2

1/2 = 0.5

0.5 = 50%

(Could explain slightly more but this should get the point across!)

Melissa can buy an 8 pound bag of dog food for $7.20. Which bag has an equivalent cost?

Answers

why is melissa buying 8 pounds worth of dog food holy shzt anyways the 4thhh

How do you make a circle graph without any extra space?

Answers

Answer:

draw a circle, and draw the degrees

Step-by-step explanation:

When resting, a spring measures 73.3 millimeters. When the spring is
compressed, it measures 51.29 millimeters. Find the percent of
decrease in the length of the spring. Round to the nearest percent if
necessary

Answers

Answer:

  -30%

Step-by-step explanation:

The percentage change in length is given by ...

  percent change = ((new length) -(original length))/(original length) × 100%

  = (51.29 -73.3)/73.3 × 100%

  = -22.01/73.3 × 100% = -0.30027 × 100%

  = -30%

The decrease in the length of the spring was 30%.

Answer:

30

Step-by-step explanation:

because divide

Foster is centering a photo that is 9 1/2 inches wide on a scrapbook page that is 10 inches wide. How far from each side of the page should he put the picture? Enter your answer as a mixed number. / pls help quick

Answers

Answer:

should be 1/4 inches away from each side

Step-by-step explanation:

all I did was take the 10 inches,subtract 9.5 from that to get 1/2 left.

since it needs to be centered, divide that by two for each side.

and 1/2 ÷ 2 = 1/4

so I got 1/4 inches on each side.

What is 13% of 50% of 329,500,000

Answers

First, multiply 0.5 and 329,500,000 to get 164750000. Then, multiply 0.13 and 164750000 to get the final answer which is 21417500

Answer:

21417500

Step-by-step explanation:

Calculate 50% of the given amount then 13% of result

50% of 329500000

= [tex]\frac{50}{100}[/tex] × 329500000

= 0.5 × 329500000

= 164750000

Then

13% of 164750000

= [tex]\frac{13}{100}[/tex] × 164750000

= 0.13 × 164750000

= 21417500

€1 = £0.85. Change €345 into £.

Answers

Answer:

£293.25

Step-by-step explanation:

If 1 euro is worth 0.85 pounds, the total of 345 euros is 0.85 times the value of a single euro. This is therefore 0.85 * 345, or £293.25.

Solve the equation.

2x+4+8x=24

Answers

2x + 4 + 8x = 24

2x + 8x = 24 - 4

10x = 20

x = 20 ÷ 10

x = 2

____

Hope it helps!

꧁✿ ᴿᴬᴵᴺᴮᴼᵂˢᴬᴸᵀ2222 ✬꧂ ❤

Answer:

[tex]\boxed{\boxed{\sf x=2}}[/tex]

Step-by-step explanation:

[tex]\sf 2x+4+8x=24[/tex]

Combine like terms:

[tex]\sf 2x+8x+4=24[/tex][tex]\sf 10x+4=24[/tex]

Subtract 4 from both sides:

[tex]\sf 10x+4-4=24-4[/tex][tex]\sf 10x=20[/tex]

Divide both sides by 10:

[tex]\sf \cfrac{10x}{10}=\cfrac{20}{10}[/tex][tex]\sf x=2[/tex]

____________________________

write answer in scientific notation. (2.66×10¹³)÷(9.5×10⁵)​

Answers

Answer: 28,000,000

Step-by-step explanation:

This is a long one.

Start with (1) 2.66 times 10 to the 13th = 26,600,000,000,000 {2.66E13}

(2) 9.5 times 10 to the 5th = 950,000

(3)  2.66E13 divided by 950,000 = 28,000,000

If this dosnt make any sense dont hesitate to say so.

C(x)= 500000 +80x+0.003x^2 me ayudan hallar por favor

Answers

Answer:

It's a parabola with a minimum.

C(x)= 500,000 + 80x + 0.003x^2

C'(x) = 80 + 0.006x = 0

x = 80/0/006 = 13,333 units

Step-by-step explanation:

A company that produces chemicals used in manufacturing sells a certain product for $200 per unit. The total production cost for the product is

C(x)= 500,000 + 80x + 0.003x^2

The company can produce no more than 30,000 units during a given time period. How

many units of the chemical product should be manufactured and sold to maximize profit?

Write a quadratic function in standard form with axis of symmetry x=-5 and y -intercept 3 .

Answers

Answer:

follow the statement below

Step-by-step explanation:

The question you presented here has multiple (un-limited) solutions unless you have another condition to solve for a single solution.

Equation: y = ax² + bx + c

y intercept (0 , 3): c = 3

axis of symmetry x=-5, therefore a corresponding point (-10,3) on the curve

3 = a*(-10)² + b*(-10) + 3

100a - 10b = 0

b = 10a  .... any pair like a=0.5 b=5; a=1 b=10 0r a=2 b=20 ..... all fit the function

y = 0.5x² + 5x +3

y = x² + 10x + 3

y = 2x² + 20x +3

........................

30 points and brainliest answer asap pls

Answers

Answer:

ed - 7e = 4d + 3

ed - 4d = 3 + 7e

d( e - 4) = 3 + 7e

d = (3 + 7e)/( e - 4 )

3.53 divided by 51
24.2 divided by 42
9.13 divided by 23
79.2 divided by 39

Answers

Answer:

1. 0.0692156863

2. 0.5761904762

3. 0.3969565217

4. 2.030769231

Step-by-step explanation:

A school of salmon was swimming in the river 5 feet below the surface. To escape a hungry bear, they went down another 3 feet.
What is the position of the salmon now relative to the surface?

Answers

Answer:

-8 feet

Step-by-step explanation:

5 + 3 = 8

Answer:

its 8 feet down...

Step-by-step explanation:

just add 5 plus 3 ? well maybe your doing the math different if it's wrong I'll edit it to make it right.

$75 to $25 show your work

Answers

Answer:

decrease

Step-by-step explanation:

the percent change measures FROM the first value. A change from 50 to 75 is a change of 50% (25 is the difference between the two numbers, and 25 is 50% of 50). A change from 75 to 50 is a change of -33.3% (25 is still the difference between the two. 25 is 33.3% of 75

4(x+6)=3x-7 please could you help me

Answers

Hello!

Let's use the Distiributive property:

4(x+6)

4x+24

4x+24=3x-7

Move all the variables to the left:

4x-3x=-7-24

x=-31

Hope this helps!

~Just a determined gal

#CarryOnLearning

[tex]MysteriousNature[/tex]

Solve. −2/9x+2.7=4 Enter your answer as a decimal or as a mixed number in simplest form in the box. x =

Answers

Answer:

−5 17/20

Step-by-step explanation:

I took the test lol

The distance, d, that an object foto is directly proportional to the square of the time, t, it has been in free fall. An object that has been in free fall for 8 seconds has fallen 1024 feet. Determine the distance the object has fallen if it has been falling for 2 seconds

Answers

Answer:

d = 64 feet

Step-by-step explanation:

Given that d is directly proportional to t² then the equation relating them is

d = kt² ← k is the constant of proportion

To find k use the condition t = 8 , d = 1024 , then

1024 = k × 8² = 64k ( divide both sides by 64 )

16 = k

d = 16t² ← equation of proportion

When t = 2 , then

d = 16 × 2² = 16 × 4 = 64 feet

A rectangle has a length that is 4 inches longer than it’s width .its perimeter is 36 inches which of the following is its area
54
64
77
81

Answers

Answer:

Area=77

Step-by-step explanation:

P=36

P=2l+2w

l=w+4

P=2(w+4)+2w

P=2w+8+2w

P=4w+8

36=4w+8

28=4w

w=7

l=7+4

l=11

A=lw

A=77

The answer is 77 please mark as brainliest i need pints

-18<3(x+2)<12

⚠️Compound Inequality⚠️

Answers

Answer:

-8<x<2

Step-by-step explanation:

divide everything by 3 to get -6<x+2<4. next subtract 2 from everything to get -8<x<2

Please help me with this!! I will mark brainlist!!

Answers

Answer:

54°

Step-by-step explanation:

Your triangle is isosceles. You have been given the third angle, and you have been asked to find the measure of one of the two equal angles. We know that the internal angles of a triangle sum to 180, so [tex]72+x+x=180 \rightarrow 2x=108 \rightarrow x = 54[/tex]

From a box of 120 mangoes, Brent sold 60%. How many mangoes were left?

Answers

Given:-

From a box of 120 mangoes, Brent sold 60%.

To Find :-

How many mangoes are left .

Solution :-

According to the question, box has 120 mangoes . The number of mangoes he sold will be ,

[tex]\longrightarrow[/tex] n(sold) = 60% of 120

[tex]\longrightarrow[/tex] n(sold) = 60/100 × 120

[tex]\longrightarrow[/tex] n(sold) = 3/5 × 120

[tex]\longrightarrow[/tex] n(sold) = 72

Hence the number of mangoes left will be ,

[tex]\longrightarrow[/tex] n(left) = 120 - 72

[tex]\longrightarrow[/tex] n(left) = 48

Hence the number of mangoes left is 48.

[tex]\boxed{\sf 2x+31=5}[/tex]

Answers

2x + 31 = 5

2x = 5 - 31

2x = -26

x = -26/2

x = -13.

_______

꧁✿ ᴿᴬᴵᴺᴮᴼᵂˢᴬᴸᵀ2222 ✬꧂

[tex] \sf \: 2x + 31 = 5[/tex]

[tex]\sf \longmapsto \: 2x = 5 - 31[/tex]

[tex]\sf \longmapsto \: 2x = -26[/tex]

[tex]\sf \longmapsto{x }= \frac{ - 26}{2} [/tex]

[tex]\sf \longmapsto \: x = - 13[/tex]

[tex] \boxed{\sf - 13}[/tex]

Which table is not a proportional relationship

Answers

Answer:

B and D

Step-by-step explanation

Answer:

D

Step-by-step explanation:

sequence in the earnings is unproportional difference between 27 and 54 is not 9

In a fraction, the value that represents the number of parts as compared to the whole is the ______

Answers

Answer:

Its the Denominator.  Hope I helped please mark brainliest if you can and thanks! <3

Step-by-step explanation:

Answer:

21

Step-by-step explanation

OUI BONSEIUR

Other Questions
QUESTION 8In the 2000 census, many Americans of African descent took advantage of the new option to identify asO Africannon-white HispanicO non-Europeanmultiracial The six seventh grade classes held a fundraiser where they sold candy bars. The school's principal award a $1000 prize to be divided between the six classes. If each class sold a different quantity, what would be the most equitable way to divide the money based on their sales ? If 8, 200 candy bars were sold, simulate how you divide the money between the six classes . Find the slope of the line x=+6 Which statement best describes the relationship between the stock market and herd behavior?Group of answer choicesHerd behavior contributes to stock market changes because it compels stockbrokers to act on emotion rather than reason.Stock market employees work in a constant state of anxiety, much like herd animals.Stock market bubbles and crashes are sometimes caused by herd behavior but are most often caused by fear.Both herd behavior and the stock market are motivated mainly by greed, which prevents people from using logic and reason. John Colet caused a sensation with his lectures on the Epistles of: Peter John Paul Timothy The three major types of stressors at work are _______. A. Criticism, presumption, and gossip b. Criminals, pressure and grimness c. Criticism, pressure, and gossip d. Criminals, presumption, and grimness. what equations are equivalent to 60% of 25 Consider the ratio of boys to girls of 4:5.a) What is the total number of parts?b) What fraction of the total are boys?c) What fraction of the total are girls?d)If there were 18 students in total,how many of them are boys?e)If there were 18 students in total, how many of them are girls? What would be the complimentary strand for the DNA sequence ATAACGA Part ATriangle ABC is reflected across theX-axis to form triangle A'B'C'. What arethe coordinates of C after thereflection? (Draw the image across theTaxis)Do76A. (-6,4)B. (3,-2)C. (4, -6)D. (6,-4) while playing in the classroom during intermission two boys accidentally smashed the window panes. As prefect of the class write a formal report to be sent to your form teacher Emmanuel thrives when he is assigned to projects that are mostly self-directed. He can be trusted to work on the project independently and check in with his supervisor as needed. Emmanuel also prefers to be paid incentives for quality work. Emmanuel likely has Bumuo ng limang pangungusap tungkol sa paksang "Batang Pilipino , Kayang Magtagumpay". Computer It costs Mak Company $ 28 of variable costs and $ 12 of allocated fixed costs to produce an industrial trash can that sells for $ 60 . A buyer in Mexico offers to purchase 3,000 units at $ 36 each Mak has excess capacity and can handle the additional production . What effect will acceptance of the offer have on net income Arrange the events for the hydrolysis of amide bonds by chymotrypsin in their correct order. 1. attack by Ser 195 to give a tetrahedral intermediate2. protonation by His 57 and release of the free C-terminus of the hydrolyzed bond 3. protonation by His 57 and release of the free N-terminus of the hydrolyzed bond 4. attack by water, leading to formation of a tetrahedral intermediate 5. binding of substrate to properly position the scissile bond for cleavagea. 5, 1, 3, 4, 2 b. 5,1,2,4,3 5, c. 1, 3, 2,4 5, d. 2, 4, 3, 1 B. Complete the missing factors of the following polynomials.5. 6a2 + 11b 35b2 = ( 3a ______ )( 2a ________ )6. 18x2 39x + 20 = ( 3x 4 ) ( ___________ )CAN SOMEONE HELP ME, PLEASE. help with this question Which is larger? 12 milligrams or 12 kilograms Why might African-American soldiers have expected less prejudice anddiscrimination at home after the war? PLEASE HELP FAST Which one of the following tissues is illustrated by the sketch? A. xylem C. Collenchyma B. Parenchyma D. Epidermis