If tracing exercise:
1. Given this class, find the return values of the calls at the bottom:
public class Trace
{
public static double tracer (int a) {
if (a < 5 || a > 10){
a = a - 7; }
else if ( a < 8){
a = a + 5;}
else{
a = 1; }
if (a > 5 && a < 10 || a == 1) {
a = a + 100; }
else {
a = a - 100;}
return a;
}
public static String wordTrace
(String start){
int pos = start.indexOf(";");
if (start.substring(pos+1,pos+2).equals("
"))
{
return start.substring(0,pos) + "," + start.substring(pos+2);
}
else
{
return start.substring(0,pos)
+ "," + start.substring(pos+1);
}
}
}
a) What is the return value of tracer(6)?
b) What is the return value of tracer(11)?
c) What is the return value of tracer(9)?
d) What is the return value of tracer(1)?
e) What is the return value of tracer(7)?
f) What is the return value of wordTrace(“amy;jones;smith”)?
g) What
is the return value of wordTrace(“mary;
grace; cocoa”)?