Java Reference
In-Depth Information
two-dimensional array and displays the location of the largest element in the
array. Here is a sample run:
Enter the number of rows and columns of the array:
Enter the array:
3 4
23.5 35 2 10
4.5 3 45 3.5
35 44 5.5 9.6
The location of the largest element is at (1, 2)
**7.14
( Explore matrix ) Write a program that prompts the user to enter the length of a
square matrix, randomly fills in 0 s and 1 s into the matrix, prints the matrix, and
finds the rows, columns, and diagonals with all 0 s or 1 s. Here is a sample run of
the program:
Enter the size for the matrix:
0111
0000
0100
1111
All 0s on row 1
All 1s on row 3
No same numbers on a column
No same numbers on the major diagonal
No same numbers on the sub-diagonal
4
*7.15
( Geometry: same line? ) Programming Exercise 5.39 gives a method for testing
whether three points are on the same line.
Write the following method to test whether all the points in the array points are
on the same line.
public static boolean sameLine( double [][] points)
Write a program that prompts the user to enter five points and displays whether
they are on the same line. Here are sample runs:
Enter five points:
The five points are not on the same line
3.4 2 6.5 9.5 2.3 2.3 5.5 5 -5 4
Enter five points:
The five points are on the same line
1 1 2 2 3 3 4 4 5 5
*7.16
( Sort two-dimensional array ) Write a method to sort a two-dimensional array
using the following header:
public static void sort( int m[][])
 
Search WWH ::




Custom Search