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

Write the output that these lines of code generate. Use the following variables

ID: 3909764 • Letter: W

Question

Write the output that these lines of code generate. Use the following variables and methods.

---------------------------------------------------------------------------

// MAIN int a = 6; int b = 8; int c = 2;

------------------------------------------------------------------------------

private static int foo(int b, int c)

{ r

eturn b-c;

}

------------------------------------------------------------------------------------

private static void bar(int a, int b)

{

int temp = a; a = b; b= temp;

}

------------------------------------------------------------------------------------------

question 1:

System.out.println( a + b * c);

Output: ? (answer 22, can you describe how this was found?)

--------------------------------------------------------------------------

question 2:

System.out.println((double)(a+b+c)/3);

output: 5.333333333 (why?)

------------------------------------------------------------------------------------------

Question 3

System.out.println( foo( a, b) );

Output: -2 (why?)

------------------------------------------------------------------------------------------

Question 4

bar( a, b );

System.out.println("a = " + a +

", b = " + b);

Output: a= 6 b=8 (why?)

Explanation / Answer

question 1:

System.out.println( a + b * c);

Output: ? (answer 22, can you describe how this was found?)

Explanation:-

---------------------------------------------------------

question 2:

System.out.println((double)(a+b+c)/3);

output: 5.333333333 (why?)

Explanation:-

------------------------------------------------------------------------

Question 3

System.out.println( foo( a, b) );

Output: -2 (why?)

Explanation:-

------------------------------------------------------------

Question 4

bar( a, b );

System.out.println("a = " + a +

", b = " + b);

Output: a= 6 b=8 (why?)

Explanation:-