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

2/7 x (-7/9) xdx lel'jobrfjb13rgifj2noinf ehelp

Answers

When multiplying by fractions you multiply the numerator by the numerator and the denominator by the denominator. 2x-7=-14. 7x9=63 so the answer is -14/63. Hope that helped :D

JELLY BEANS A large jar contains B blue Jelly beans and R red jelly beans. A bag of 100 red and 100 blue jelly beans is added to the jar. What is the ratio of red to blue jelly beans in the Jar?


PLEASE HELP ME. Would very much appreciate it ​

Answers

Answer:

100:100

Step-by-step explanation:

100 reds and 100 blues are in there

If RS=x+5 and HJ + Lk = 4x+6, find RS

Answers

the answer is RS= -1.5

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?

can someone help me on this and tell me how you did it you will get 30 points

Answers

[tex] \frac{2}{3} \div 3 \frac{1}{3} \\ \frac{2}{3} \times \frac{3}{10} \\ = \frac{2}{10} = \frac{1}{5} [/tex]

- BRAINLIEST answerer

What is the value of the function y= 2x – 3 when x = -1?
O --5
O-1
o 2
03

Answers

Answer:

y= 2x-3

when X= -1

y= 2(-1)-3

y= -2-3

y= -5

The value of the given function y=2x-3 is  -5 when x=-1

What is a function?

A function is a correspondence from the two set A to set B in which each element of set A has a unique image in B. Generally we denote a function by f or y.

Here the given function is y=2x-3

Putting x= -1 in the given function y=2x-3 , we get

y= 2(-1) -3

y= -2-3

y= -5

Hence the value of the function y= 2x-3 is -5 when x=-1 .

To learn more about function click here:

https://brainly.com/question/25649287

#SPJ7

Select the system that has the same solution as
–2x+2y = -5,
5x — бу = 8

Answers

The answer is the the second or B

What is the slope of the line?
y-4=-7(x-6)

Answers

Answer:  −7

Step-by-step explanation:

18= 1.57(multiply sign) X^2.2

please give me steps!!!

Answers

Answer: x = 3.030631 approximately

Explanation:

If you want to solve for x, then you could follow these steps:

[tex]18 = 1.57*x^{2.2}\\\\18/1.57 = x^{2.2}\\\\11.464968 \approx x^{2.2}\\\\x^{2.2} \approx 11.464968\\\\x \approx (11.464968)^{\frac{1}{2.2}}\\\\x \approx 3.030631\\\\[/tex]

In the second to last step, we have the value 11.464968 raised to the exponent of 1/(2.2) which is done to undo the exponent of 2.2 in the previous line.  The rule used is [tex]a^b = c \to a = c^{1/b}[/tex]

Tim earns spending money by doing odd jobs for his neighbors. The table shows how much he is paid
for each job. Tim gets $12 for mowing lawns, $9 for washing cars, and $7 for walking dogs. Mr. Jeffries has not paid his bill in 3 weeks. If Tim performed each job for Mr. Jeffries
once, how much does Mr. Jeffries owe Tim? Write an addition equation using integers to represent the
situation. Represent Mr. Jeffries' balance as an integer.
Select the correct choice below and fill in the answer boxes to complete your choice.

Answers

Answer:

D ($28)

Step-by-step explanation:

-12 + -9 + -7 = -28

NEED HELP WITH 13 a-b!!!! PLEASE HELP!!!!!!!

Answers

Answer:

a - 6%

b - $7.50

Step-by-step explanation:

The answer for a

the only items that had sales tax were $3.00 and $0.50. The total tax for the both was $0.21 so you can find what percent 0.21 is of 3.00 + 0.50 o 3.50. Do this by dividing the percent you are looking for, 0.21, by what it is the percent of 3.50. 0.21 / 3.50 = 0.06. then you multiply the number you got, in this case 0.06 by 100 to find the percentage so it is 6%

The answer for b

Here you can just take the subtotal, $13.00, and subtract all the other prices and you will be left with the price of the top. 13.00 - 3.00 - 2.00 - 0.50 = 7.50. So the answer is $7.50

7th grade math help...

Answers

Answer:

a= 11/30

Step-by-step explanation:

Divide the 5 1/2 miles by the 15 minutes

5.5/15= .36

.36 = 11/30    

Find the perimeter. Simplify your answer.

Answers

Step-by-step explanation:

perimeter =

2(L+B)

=2× (7z+3 +3z+5)

2×10z +8

=20z+16

(c) Ada is x years old and Bill is y years old.
Last
year,
Bill was 6 times as old as Ada.
(1) Form an equation in x and y and show that it simplifies to y = 6x - 5.

Answers

Using a system of equations, it is found that the simplified equation is y = 6x - 5.

Ada is x years old.Bill is y years old.

Last year, Ada was x - 1 years old and Bill was y - 1 years old.

Bill was 6 times as old as Ada, hence:

[tex]y - 1 = 6(x - 1)[/tex]

[tex]y - 1 = 6x - 6[/tex]

[tex]y = 6x - 6 + 1[/tex]

[tex]y = 6x - 5[/tex]

The simplified equation is y = 6x - 5.

For a similar problem, also involving a system of equations, you can check https://brainly.com/question/13773803

Please can you help me x

Answers

Answer:

PX : XQ = 2 : 5

Step-by-step explanation:

Since RX is perpendicular to PQ , then

Δ RPX and Δ RQX are right triangle

Calculate PX and XQ using Pythagoras' identity in the right triangles

PX² = 20² - 16² = 400 - 256 = 144 ( take square root of both sides )

PX = [tex]\sqrt{144}[/tex] = 12

Similarly

XQ² = 34² - 16² = 1156 - 256 = 900 ( take square root of both sides )

XQ = [tex]\sqrt{900}[/tex] = 30

Then

PX : XQ = 12 : 30 = 2 : 5 ( in simplest form )

f(x)= 2/3x+5 for f(15)
solve for f(15)
pls help im taking a test rn and failing my grade Q-Q

Answers

15 is the answer for the question

Answer:

So......cheating eh? jk, the answers 15

Step-by-step explanation:

you plug in 15 for x ==> 2/3 x 15 + 5 = f(15)

simplify ==> 10+5 = f(15)

so f(15) = 15

cahahahahhddbsbshshsjs 98 +_=366

Answers

Answer:

268

Step-by-step explanation:

366 minus 98= 268

CAN I GET BRAINLIEST

268
You get the final amount given minus that by the first number given you will get the answer for this case it would be.
366-98 that would be 268

What is the least common denominator of 11/12 5/6 1/5

Answers

Answer:

11/12 = 132

5/6 = 30

1/5 = 5

All of the numbers after the equal sign, are LCDs of the fraction.

Have a great day friend! :D

Answer:

60

Step-by-step explanation:

Will mark brainiest if right Is this function linear or nonlinear?

y=3x−5

Answers

Answer: This function is linear because it forms a straight line when graphed.

Would appreciate brainly <3

Which expression is an equivalent expression for 2(6y – 4)?
A. 8x – 2
B. 12y – 8
C. 8y
D. 12y + 4

Answers

Answer:

B. 12y-8

Step-by-step explanation:

by multiplying the 2 through the equation

Can someone help ?????

Answers

Accordingly the answer is Nineteen Fourths.

I need help on this one

Answers

Answer:

(3,5)

1/3

Step-by-step explanation:

The equation is already in point-slope form. Therefore, both the point and slope can easily be found in the equation. Point slope form looks like [tex]y-y_{1}=m\left(x-x_{1}\right)[/tex]. In this the point is [tex](x_{1},y_{1})[/tex] and the slope is m. So, the x value is 3 and the y value is 5, making the coordinate (3,5). Finally, the slope is 1/3.

~~ 3,5
1/3
Hope this helps <3

What is the midpoint of KL?

Answers

Answer:

Find the midpoint between the two points.

(4,4),(-1,2)

5p + 3 = 15 Write a situation that this equation could help you solve and explain how each part of the equation relates to the situation you create.

Answers

Expressions can be represented as equations, and vice versa.

A possible situation is as follows:

John is 15 years old, and his age is 3 more than 5 times his brother's age

The equation is given as:

[tex]\mathbf{5p + 3 = 15}[/tex]

This means that:

15 represents John's ageP represents his brother's age5 and 3 are the constants that relate their ages

Read more about word equations at:

https://brainly.com/question/20518082

The equation 5p + 3 = 15 can be used to find Mgbafor's age when  Okeke's age is five times Mgbafor's age and in three years time, Okeke will be 15 years old.

The equation 5p + 3 = 15 is a linear equation. The equation must represent a variable which when multiplied by 5 and 3 is added yields 15.

Lets assume that Okeke's age is five times Mgbafor's age In three years time, Okeke will be 15 years old. If i am asked to find Mgbafor's age, the equation to use is 5p + 3 = 15, where p = Mgbafor's age.

Learn more: https://brainly.com/question/11897796

please help asap…………

Answers

Answer:

not linear

Step-by-step explanation:

a linear function contains x and y only with the exponent 1.

this allows the function to be a line (hence the term "linear"), a constant ratio of y changes to x changes for any values of x which defines linear relation between x and y.

but this equation contains a term with x², which changes the size of change of y for every value of x.

e.g. when x changes by 1 from 1 to 2, y changes by 3 from 1² to 2² (1 to 4). but if x changes again by 1 from 2 to 3, y changes by 5 from 2² to 3² (4 to 9).

this is clearly not constant.

Please help me with this homework homework

Answers

Answer:

Its A=2.38

Step-by-step explanation:

6cup=558 gram

1cup=558/6

1cup=93 gram

13gram*17kg=221gram

221/93=2.38

I think the answer is A.

Enter the number in scientific notation. 86,792 =

Answers

Answer:

8.6792 × 10 4 (I don't know how to make the four smaller but its 10 to the power of 4).

Step-by-step explanation:

8.6792 × 10 4. is the scientific notation

How many factors of 2 are there in 2³? answers> 1 2 3 5​

Answers

Answer:

2

Step-by-step explanation:

2^3= 2*2*2

factors of 8= 1,2,4,8

factors of 2= 1,2

Multiply.

[−8⋅4/11]⋅[(−0.1)⋅22]

Answers

Answer:

6.4

Step-by-step explanation:

Hope this helps :D

Hehehjsbusbsysbsusniwnwiwkwiwn

Can you help me please?​

Answers

Answer:

B

Step-by-step explanation:

The Pythagoras theorem states that [tex]c^{2} = a^{2} + b^{2[/tex], where [tex]c[/tex] is the hypotenuse and a and b are the adjacent and opposite sides of the hypotenuse. If we made [tex]a[/tex] the subject of the expression, the expression will be re-written as [tex]a^{2} = c^{2} - b^{2}[/tex], which is the correct answer.

Other Questions
Together, erosion and deposition help shape sand dunes, ____ and deltas. a psychological disorder is a syndrome marked by a clinically significant disturbance plz hurryWhich option shows the rhyme scheme of this poem? Roses are red, violets are blue, lilacs are purple, and pansies are too. What is short-run in production function ?[tex] \: \: [/tex] IS the square root of 16 rational or irrational and why? How many decimals in multiplication. goodmorning everyone, today is going to be an amazing day dont let anyone bring you down today! remember to love your self!!! Which step of cellular respiration uses oxygen. When you mail a package that weighs more than one ounce, the Post Office charges 34 cents for the first ounce and 23 cents for each additional ounce.Write a mathematical model of this question (in words). Let N stand for the number of ounces.Total Cost =How much does a package that costs $2.18 weigh? what is the length of the hypotenuse of the triangle when x=13 does the government of the United States works for everyone living in this country? What are the major theories of the origin of the state? Which do you find most convincing and why? (Branliest) Please give me the answer to these I need help plz and thxs :) Do you think counselors are trustworthy. Which scientist most influenced the literary movement or style known as naturalism? Imagine that you are a writer for a leading newspaper company in the philippines brainly. ASAP!! PLEASE!!"That can never be necessary," cry the other side. "All men are privately influenced by women; each has his wife, sister, or female friends, and is too much biased by these relations to fail of representing their interests. And, if this is not enough, let them propose and enforce their wishes with the pen. The beauty of home would be destroyed, the delicacy of the sex be violated, the dignity of halls of legislation degraded, by an attempt to introduce them there. Such duties are inconsistent with those of a mother;" and then we have ludicrous pictures of ladies in hysterics at the polls, and senate-chambers filled with cradles.How does paragraph 4 contribute to the development of Fullers argument for equality for women?by presenting the counterargument of men that has hindered the advancement of womens rightsby warning men of ways that government will change once women are given opportunities to leadby addressing the concern that too much independence for women can lead to conflict in societyby asserting that the majority of men share womens desire for social change and womens rights Which line from The Scarlet Letter provides the best characterization of Pearl's personality? If the children gathered about her, as they sometimes did, Pearl would grow positively terrible in her puny wrath, snatching up stones to fling at them... The infant, during the latter portion of her ordeal, pierced the air with its wailings and screams. Wouldst thou avenge thyself on the innocent babe? The child's attire, on the other hand, was distinguished by a fanciful, or, we might rather say, a fantastic ingenuity... How do weak intermolecular bond strengths affect the melting and boiling point of a substance?The melting point is lower, but the boiling point is higher.Both the melting point and boiling point are lower.The melting point is higher, but the boiling point is lower.Both the melting point and boiling point are higher.