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

I. In the left column of the following table is a program that contains boolean

ID: 3787625 • Letter: I

Question

I. In the left column of the following table is a program that contains boolean variable declarations and assignments. Fill in the values of the variables on the right after each line runs. If a variable has not yet been declared, write a question mark (m. If a variable has not yet been initialized, write an asterisk Statement boolean a false; boolean b; b a true a true; a b II true; b a && (a II b); 2. Given int a and int b with some value in each of them, explain in your own words: (a) Can (a b) && (a b) ever be true? (b) Can (a b) II (a b) ever be false? 3. The following program calculates the value for r based on three input values. Please answer the following questions about the program. int x console. promptint (a-b) For the given inputs for x, y, z, what will int y console. promptint be the value of r after the if else statement int z console promptint evaluates? int r if (x

Explanation / Answer

1.

2.

a)

(a>b)&&(a<=b)

Here there is no chance of getting true from above statement .

First given that a is greater than b and second is a is les than or equal to b.

If first statement is true then there is no chance that the second statement is true.

Because If a>b then how it could be less than or equal to b.

so if one statement is true then other statement is false.
here they gave us and statement between two statements , so if we apply and operation between true and false then we get false.

So this statement never be true, always it leads to false.

b)

(a>b)||(a<=b)

Here there is no chance of getting true from above statement .

First given that a is greater than b and second is a is les than or equal to b.

If first statement is true then there is no chance that the second statement is true.

Because If a>b then how it could be less than or equal to b.

so if one statement is true then other statement is false.
here they gave us or operation between two statements , so if we apply or operation between true and false then we get true.

So this statement will be true.

3)

r values:

a : 7;

b: 5;

c: 8;

4)

Number of Iterations:

a) 10

b) 0

c) Infinity

5)

7)

a)

8 6 4 2

b)

int i=10;
while(i>0)
{
i=i-2;
console.print(i);
}

8)

If we don`t give any condition inside the loop then it will definitely executes for one time.

example: for(i=0; ;i++)

10)

In line 3 it is given that if(i=0) but it has to written as if(i==0)

In line 4 here placed a semicolon after if statement we have to remove that semicolon.

Thankyou

STATEMENT a b boolean a=false; false ? boolean b false ? b=a==true false false a=a!=true true false a=b||true true false b=a&&(a||b) true true