Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with the following assingment in Java. Match the following terms to

ID: 3886787 • Letter: I

Question

I need help with the following assingment in Java.

Match the following terms to the definition below. Note that there are more terms than definitions.

!

&&

||

<

=

break

continue

else

do…while

for

if

static

switch

while

Which term from the above word bank matches each description below?

1) This operator can be used to ensure that two conditions must both be true

2) These methods perform common tasks and do not require objects

3) This statement selects among multiple actions based on the possible values of an integer variable or expression, or a String

4) This statement specifies all the details of counter-controlled repetition in its header

5) The body of this loop always executes at least once

6) This unary operator reverses the value of a condition

7) A case’s statements typically end with what statement

Answer the following questions:

8) What errors are present in the following code snippet:

int j;

For (j = 10, j >= 1, j++)

     System.out.println(j);

9) How many times does the following loop execute?

int i;

for ( i = 19; i >= 1; i -= 2 )

System.out.println( i );

10) What does the following code output?

int i;

int j;

for (i = 1; i < 3; i++)

   for (j = 1; j < 4; j++)

               System.out.print("%d ", (i * j));

11) What is the output of the following code?

int x = 0;

do

{

   System.out.println(x);

x++;

} while (x > 10);

12) What is the output of the following code?

int value = 0;

switch ( value )

{

         case 0:

                   System.out.println( "zero" );

        case 1:

                  System.out.println( "one" );

}

13) Let i = 1, j = 2, k = 3 and m = 2.Evaluate each of the following (true or false).

a)    i == 1

b)   ( i >= 1 ) && ( j < 4 )

c)   ( j >= i ) || ( k == m )

d)   ( k + m < j ) | ( 3 - j >= k )

e)    !( k > m )

Explanation / Answer

1) This operator can be used to ensure that two conditions must both be true

Answer: &&

2) These methods perform common tasks and do not require objects

Answer:

do…while

for

while

3) This statement selects among multiple actions based on the possible values of an integer variable or expression, or a String

Answer: switch

4) This statement specifies all the details of counter-controlled repetition in its header

Answer:while

5) The body of this loop always executes at least once

Answer:do-while

6) This unary operator reverses the value of a condition

Answer:!

7) A case’s statements typically end with what statement

Answer:bresk

Answer the following questions:

8) What errors are present in the following code snippet:

int j;

For (j = 10, j >= 1, j++)

     System.out.println(j);

Answer:For should be for and j== should be j--

9) How many times does the following loop execute?

int i;

for ( i = 19; i >= 1; i -= 2 )

System.out.println( i );

Answer:10 times

10) What does the following code output?

int i;

int j;

for (i = 1; i < 3; i++)

   for (j = 1; j < 4; j++)

               System.out.print("%d ", (i * j));

Answer:1 2 3 2 4 6

11) What is the output of the following code?

int x = 0;

do

{

   System.out.println(x);

x++;

} while (x > 10);

Answer: 0

12) What is the output of the following code?

int value = 0;

switch ( value )

{

         case 0:

                   System.out.println( "zero" );

        case 1:

                  System.out.println( "one" );

}

Answer:

zero
one

13) Let i = 1, j = 2, k = 3 and m = 2.Evaluate each of the following (true or false).

a)    i == 1 Answer: True

b)   ( i >= 1 ) && ( j < 4 ) Answer: True

c)   ( j >= i ) || ( k == m ) Answer: True

d)   ( k + m < j ) | ( 3 - j >= k ) Answer:False

e)    !( k > m )Answer:False