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 assignment in Java. Match the following terms to

ID: 3886560 • Letter: I

Question

I need help with the following assignment in Java.

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

*=

=*

**

(double)

<double>

(floating)

<floating>

0

1

block

box

counter-controlled

if

if…else

garbage

group

nested

post-fix

pre-fix

sentinel

sequence

set

strongly-typed

weakly-typed

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

This value can be used to terminate repetition when the number of iterations is not known in advance

Default value for instance variables of type int, bool, double

Use this type of loop when the number of iterations is known in advance

Statement is used to execute one action when a condition is true and another when that condition is false

Can use this compound operator toshorten: a = a * 2

A language that requires all variables to have a type

x++ is ____ increment

A control statement inside another control statement

Used to make a temporary floating-point copy of its operand

A set of statements contained in a set of { }’s

Answer the following questions:

Write 4 different ways to add 1 to the integer variable num

How many times does the following loop execute?

int i = 0;

while (i <= 2)

{

   System.out.println("in the loop");

   i++;

}

What does the following code output?

int i = 3;

if (i == 2);

   System.out.println("in if");

System.out.println("after the if");

How many times does the following loop execute?

int x = 0;

int total = 0;

while (x < 5)

   total += x;

   x++;

Looking at the following code, what word do you think you should replace xxx with? yyy with?

if (num % 2 == 0)

   System.out.prinln("num is xxx");

else

System.out.prinln("num is yyy");

Explanation / Answer

*=    Can use this compound operator toshorten: a = a * 2

=*

**

(double) = Used to make a temporary floating-point copy of its operand

<double>

(floating)

<floating>

0 = Default value for instance variables of type int, bool, double

1

Block =A set of statements contained in a set of { }’s

box

counter-controlled =Use this type of loop when the number of iterations is known in advance

if

if…else =Statement is used to execute one action when a condition is true and another when that condition is false

garbage

group

nested =A control statement inside another control statement

post-fix =x++ is ____ increment

pre-fix

sentinel =This value can be used to terminate repetition when the number of iterations is not known in advance

sequence

set

strongly-typed

weakly-typed =A language that requires all variables to have a type

______________________

Write 4 different ways to add 1 to the integer variable num

1) num++ ;

2) ++num ;

3) num=num+1;

4) num += 1;

____________________

How many times does the following loop execute?

int i = 0;

while (i <= 2)

{

   System.out.println("in the loop");

   i++;

}

Ans) 3 times (for i= 0 , 1 , 2)

_________________________

What does the following code output?

int i = 3;

if (i == 2);

   System.out.println("in if");

System.out.println("after the if");

Ans)after the if

Reason: as the valu eof x =3 then the if block will not get executed .So the statement after the if block will be executed.

___________________________

How many times does the following loop execute?

int x = 0;

int total = 0;

while (x < 5)

   total += x;

   x++;

Ans) infinite times.

Reason: the value of x=0 every time the condition check 0<5 is true .But the value of x will never be incremented because x++ ; is outside the while loop.so this loop continues to execute for infinite times.

_________________

Looking at the following code, what word do you think you should replace xxx with? yyy with?

if (num % 2 == 0)

   System.out.prinln("num is xxx");

else

System.out.prinln("num is yyy");

Ans)

xxx should be replaced with even

yyy should be replaced with odd.

_____________Could you rate me well.Plz .Thank You