Professional Documents
Culture Documents
03/4
Dr. Zhizhang Shen
Fall 2004
1. A Java declaration for one real number quantity to be called rate, initialized to 5.0 is
float rate = 5.0;
2. A single Java statement that declares two integer quantities is
int orderOne, orderTwo = 0;
3. The declaration could be the following:
public static void main(String[] args){
char choice;
int inventory;
float sales;
choice = ;
inventory = sales = 0;
4. (a)
(b)
System.out.print(Math.PI);
public static final double EVAPORATION_RATE = 6.15;
5. Your program will need four variables, three to store the three quiz grades, and one to store
the average. The declarations would look like the following,
int quiz1,quiz2,quiz3,average;
6. Since the index begins with 0, one would access the eighth number in the array with the
following expression: list[7].
7. It might look like the following:
float[][] box = new float[5][7];
8. Again, since both indices begin with 0, one would access that cell by the following: table[2][2].
9. A three dimensional table would be appropriate for such geometric problems. The declaration
to implement the data structure could be the following:
float point[][][] = float[100][100][100];
11. The output statement could be the following:
System.out.println("inventoryNumber is " + inventoryNumber +
"\nnumberOrdered is " + numberOrdered);
1
1
2
3
4
5
6
7
8
20
19
18
17
16
15
14
13
return returned;
}