Java Reference
In-Depth Information
int [] scores = int [30];
int [] primes = new {2,3,5,7,11};
int [] scores = new int [30];
char grades[] = {'a', 'b', 'c', 'd', 'f'};
char [] grades = new char[];
EX 8.2
Describe five programs that would be difficult to implement
without using arrays.
EX 8.3
Describe how an element in an array is accessed in memory. For
example, where is myArray[25] stored in memory?
EX 8.4
Describe what problem occurs in the following code. What mod-
ifications should be made to it to eliminate the problem?
int [] numbers = {3, 2, 3, 6, 9, 10, 12, 32, 3, 12, 6};
for ( int count = 1; count <= numbers.length; count++)
System.out.println (numbers[count]);
EX 8.5 Write an array declaration and any necessary supporting classes
to represent the following statements:
a. students' names for a class of 25 students
b. students' test grades for a class of 40 students
c. credit-card transactions that contain a transaction number, a
merchant name, and a charge
d. students' names for a class and homework grades for each
student
e. for each employee of the L&L International Corporation: the
employee number, hire date, and the amount of the last five
raises
EX 8.6 Write code that sets each element of an array called nums to the
value of the constant INITIAL .
EX 8.7 Write code that prints the values stored in an array called names
backwards.
EX 8.8 Write code that sets each element of a boolean array called flags
to alternating values ( true at index 0, false at index 1, etc.).
EX 8.9 Write a method called sumArray that accepts an array of floating
point values and returns the sum of the values stored in the array.
EX 8.10 Write a method called switchThem that accepts two integer
arrays as parameters and switches the contents of the arrays.
Take into account that the arrays may be of different sizes.
Search WWH ::




Custom Search