Programming and Problem Solving with Java

(やまだぃちぅ) #1
629

public intmaxInRow(introw)
// Returns the maximum value in the specified row
public intmaxInCol(intcolumn)
// Returns the maximum value in the specified column
public intmaxInArray()
// Returns the maximum value in the entire array
public intsum()
// Returns the sum of the values in the array
public intsumInRow(introw)
// Returns the sum of the values in the specified row
public intsumInCol(intcolumn)
// Returns the sum of the values in the specified column
public booleanallPlus()
// Returns true if all the values are positive; false otherwise
a.Write the code for the constructor TwoDimensions.
b.Write the code for the method inputData.
c. Write the code for the method print.
d.Write the code for the method maxInRow.
e.Write the code for the method maxInCol.
f. Write the code for the method maxInArray.
g.Write the code for the method sum.
h.Write the code for the method sumInRow.
i. Write the code for the method sumInCol.
j. Write the code for the method allPlus.

3.Write a code segment that finds the largest value in a two-dimensional double
array of 50 rows and 50 columns.


4.Given the following declarations


final intNUM_DEPTS = 100 ;
final intNUM_STORES = 10 ;
final intNUM_MONTHS = 12 ;
a.Declare an array variable salesthat will be indexed by the number of depart-
ments, number of stores, and number of months and that contains double
values.
b.Instantiate an array object for the variable sales.
c. What values do the components in the array have after it is created?
Free download pdf