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

a) Give all call sites using the line numbers given. (2 points) b) Give all pair

ID: 3849604 • Letter: A

Question

a) Give all call sites using the line numbers given. (2 points)

b) Give all pairs of last-defs and first-uses. (4 points)

c) Provide testinputsthatsatisfy all-coupling-uses (note thattrash() only has one input).

public class TrashAndTakeOut
{

public static void trash (int x)
{   
int m, n;   

m = 0;
if (x > 0)   
m = 4;
if (x > 5)
n = 3*m;
else   
n = 4*m;   
int o = takeOut (m, n);
System.out.println ("o is: " + o);
}


public static int takeOut (int a, int b)
{
int d, e;

d = 42*a;
if (a > 0)
e = 2*b+d;
else
e = b+d;
return (e);
}


public static void main (String []argv)
{ // Driver method for trashAndTakeOut
// Read an integer from standard input, call trashAndTakeOut()
if (argv.length != 1)
{
System.out.println ("Usage: java TrashAndTakeOut v1");
return;
}

int x = 0;
try
{
x = Integer.parseInt (argv[0]);
}
catch (NumberFormatException e)
{
System.out.println ("Entry must be an integer, using 1.");
x = 1;
}

trash (x);
}
}

Question 3 (12 points) use the hads eout() to find the owing questions 24 return Priatla a) Give all call sites using the line numbers given. (2 points of las-des and Mrs-uses 4 p c Provide test inputs that satisfy al-coupling-uses (note that trash0only ha one input (6 points

Explanation / Answer

public class TrashAndTakeOut
{

public static void trash (int x)
{   
int m, n;   

m = 0;
if (x > 0)   
m = 4;
if (x > 5)
n = 3*m;
else   
n = 4*m;   
int o = takeOut (m, n);
System.out.println ("o is: " + o);
}


public static int takeOut (int a, int b)
{
int d, e;

d = 42*a;
if (a > 0)
e = 2*b+d;
else
e = b+d;
return (e);
}


public static void main (String []argv)
{ // Driver method for trashAndTakeOut
// Read an integer from standard input, call trashAndTakeOut()
if (argv.length != 1)
{
System.out.println ("Usage: java TrashAndTakeOut v1");
return;
}

int x = 0;
try
{
x = Integer.parseInt (argv[0]);
}
catch (NumberFormatException e)
{
System.out.println ("Entry must be an integer, using 1.");
x = 1;
}

trash (x);
}
}