![]() |
![]() Second Summer 2002 |
Questions:
a
with the values:
1 2 3 4 5 6 7 8 9 10
0 2 4 6 8 10 12 14 16 18
1 4 9 16 25 36 49 64 81 100
0 0 0 0 0 0 0 0 0 0
1 4 9 16 9 7 4 9 11
a
with ten random numbers between 1 and 100. Write code
for two nested loops that fill a
with ten different random numbers between 1 and 100.
Explain two ways of fixing the error.int[] v = new int[10]; for (int i = 1; i <= 10; i++) v[i] = i * i;
Product[]
parameters that change an array
of products in each of the two ways just described.
Catalog
that stores a collection of products. What public
methods should you support? What advantages and disadvantages does a Catalog
class
have over a Product[]
array?
v
is a sorted vector of products. Describe how a
new product can be inserted in its proper position so that the resulting vector stays sorted.
Here's where the solutions are.