Java Reference
In-Depth Information
Enter the size for the matrix: 4
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
*8.15
( Geometry: same line? ) Programming Exercise 6.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: 3.4 2 6.5 9.5 2.3 2.3 5.5 5 -5 4
The five points are not on the same line
Enter five points: 1 1 2 2 3 3 4 4 5 5
The five points are on the same line
*8.16
( Sort two-dimensional array ) Write a method to sort a two-dimensional array
using the following header:
public static void sort( int m[][])
The method performs a primary sort on rows and a secondary sort on columns.
For example, the following array
{{ 4 , 2 },{ 1 , 7 },{ 4 , 5 },{ 1 , 2 },{ 1 , 1 },{ 4 , 1 }}
will be sorted to
{{ 1 , 1 },{ 1 , 2 },{ 1 , 7 },{ 4 , 1 },{ 4 , 2 },{ 4 , 5 }}.
***8.17
( Financial tsunami ) Banks lend money to each other. In tough economic times,
if a bank goes bankrupt, it may not be able to pay back the loan. A bank's
total assets are its current balance plus its loans to other banks. The diagram in
FigureĀ 8.8 shows five banks. The banks' current balances are 25, 125, 175, 75,
and 181 million dollars, respectively. The directed edge from node 1 to node 2
indicates that bank 1 lends 40 million dollars to bank 2.
 
Search WWH ::




Custom Search