Java Reference
In-Depth Information
/**
Print "true" if
x+y>z */
public static void
print4(
int
x,
int
y,
int
z)
/** =
the value of the statement
"x + y
is greater than
z" */
public static boolean
testLengths(
int
x,
int
y,
int
z)
/** =
the value of the statement
"s
contains the letter
e" */
public static boolean
containsE(String s)
/** =
the larger of
x
2
and
y
2
*/
public static int larger2(int x, int y)
For each of the following calls, state what it does, using the specifications of the
methods being called. For a procedure, the specification is a command to do
something; for a function, it is the value of the expression.
SR1
.
print3(3);
SR2
.
print4(3, 4, 5);
SR3
.
print4(a, a, b);
SR4
.
testLengths(b, b, b)
SR5
.
testLengths(b, c, c * c)
SR6
.
larger2(2, -3)
SR7
.
print3(larger2(4, -5));
SR8
.
print4(larger2(4, -5), 7, 9);
Answers to self-review exercises
SR1
. Print
3
,
3
2
, and
3
3
on a single line
SR2
. Print "true" if
3+4 > 5
SR3
. Print "true" if
a+a > b
SR4
. the value of the statement
"b + b
is greater than
b"
SR5
. the value of the statement
"b + c
is greater than
c*c"
SR6
. the larger of
2
2
and
(-3)
2
SR7
. Print
z
,
z
2
, and
z
3
on a single line, where
z
is the larger of
4
2
and
(-5)
2
.
SR8
. Print "true" if
t+7>9
, where
t
is the larger of
4
2
and
(-5)
2
.
Search WWH ::
Custom Search