Instructions: Answer the following questions one at a time. After answering each question, check your answer (by clicking on the check-mark icon if it is available) before proceeding to the next question.
Getting Ready: Before going any further, you should:
.java
Files: In most IDEs, .java
files
(i.e., source files) can just be copied into the project.
.class
and .jar
Files:
In some IDEs it is easier to use .class
files and in others it is easier to use a .jar
file
that contains the .class
files. Hence, you have been
provided with both.
See the course "Help" page on your IDE for more information.
Resources: In some IDEs, resources (e.g., images, data files) need to be in a special directory whereas in others they need to be in the working directory. See the course "Help" page on your IDE for more information.
Analytic.java
and GeometryDriver.java
.
GeometryDriver
assuming it is executed as follows:
java GeometryDriver 400
.
Analytic.findPerimeterOfSquare()
called?
Analytic.findPerimeterOfSquare()
method (and, hence, the local variables used in it) are being used
at any point in time?
Analytic.findPerimeterOfSquare()
?
Analytic.java
and open Iterative.java
.
GeometryDriver.java
, change
perimeter = Analytic.findPerimeterOfSquare(area);
to
perimeter = Iterative.findPerimeterOfSquare(area);
GeometryDriver
assuming it is executed as follows:
java GeometryDriver 400
.
Iterative.findPerimeterOfSquare()
called?
Iterative.findPerimeterOfSquare()
method (and,
hence, the local variables used in it) are being used at any point
in time?
Iterative.findPerimeterOfSquare()
?
Iterative.java
and open Recursive.java
.
GeometryDriver.java
, change
perimeter = Iterative.findPerimeterOfSquare(area);
to
perimeter = Recursive.findPerimeterOfSquare(area);
GeometryDriver
assuming it is executed as follows:
java GeometryDriver 400
.
Recursive.findPerimeterOfSquare()
called?
Recursive.increaseBy()
called?
Recursive.increaseBy()
method (and,
hence, the local variables used in it) are being used at any point
in time?
Recursive.increaseBy()
(than either the analytic algorithm
or the iterative algorithm)?
increaseBy()
:
and make
one card for main()
and one card for
findPerimeterOfSquare()
. (Note: If you're working
on this during a scheduled lab period, pre-printed cards
are available for increaseBy()
.)
GeometryDriver
assuming it is executed as follows:
java GeometryDriver 400
.
Specifically, each time a method is called, write the parameters
on a card, and put the card on a stack (that will initially be empty).
Then, trace that method.
When the method returns, write down the return value, take the card off of the stack, and replace the method call (on the next card) with the return value.
ExtreminatorDriver
. (Note: Cards are available.)
Searcher
class.
search()
method. (Note: If you're
working on this during a scheduled lab period, pre-printed cards
are available.)
search()
method
in the Searcher
class when it is passed
0
as first
, 4
as last
,
18
as target
, and the array
{1, 3, 6, 7, 10}
as data
.
search()
method
in the Searcher
class when it is passed
0
as first
, 4
as last
,
7
as target
, and the array
{1, 3, 6, 7, 10}
as data
.
search()
method
in the Searcher
class when it is passed
0
as first
, 3
as last
,
1
as target
, and the array
{1, 3, 6, 7}
as data
.
search()
method?
ChangeMakerDriver
class.
coins
array
in ChangeMakerDriver
to 3
.
10
to coins[3]
in ChangeMakerDriver
.
ChangeMakerDriver
passing it
the command-line parameter 4
.
change()
method. (Note: If
you're working on this during a scheduled lab period, pre-printed
cards are available.)
change()
method
in the ChangeMaker
class when it is passed the
array {1, 5, 8}
and the value 4
.
ChangeMaker
class.
ChangeMaker
class so that it keeps track of the
number of times the change()
method is called.
ChangeMaker
class so that it prints the
following "debugging" output:
amount
when the method is enterednumber
each time it changesmin
each time it changes
coins
array
in ChangeMakerDriver
to 4
.
10
to coins[3]
in
ChangeMakerDriver
.
ChangeMakerDriver
passing it
the command-line parameter 4
.
change()
method is called
from two different places in the change()
method.
Add "debugging" output statements that indicate which call
to change()
is being traced.
ChangeMakerDriver
using the
array {1, 5, 8, 10}
and the
value 13
.
ChangeMakerDriver
using the
array {1, 5, 8, 10}
and the
value 32
.
ChangeMakerDriver
using the
array {1, 5, 8, 10}
and the
value 36
.
Copyright 2021