Java Reference
In-Depth Information
Write a test program that prompts the user to enter two lists of integers and dis-
plays whether the two are identical. Here are the sample runs. Note that the first
number in the input indicates the number of the elements in the list. This number
is not part of the list.
Enter list1: 5 2 5 6 6 1
Enter list2: 5 5 2 6 1 6
Two lists are identical
Enter list1: 5 5 5 6 6 1
Enter list2: 5 2 5 6 1 6
Two lists are not identical
*7.28
( Math: combinations ) Write a program that prompts the user to enter 10 integers
and displays all combinations of picking two numbers from the 10.
*7.29
( Game: pick four cards ) Write a program that picks four cards from a deck of 52
cards and computes their sum. An Ace, King, Queen, and Jack represent 1, 13,
12, and 11, respectively. Your program should display the number of picks that
yields the sum of 24.
*7.30
( Pattern recognition: consecutive four equal numbers ) Write the following
method that tests whether the array has four consecutive numbers with the same
value.
VideoNote
Consecutive four
public static boolean isConsecutiveFour( int [] values)
Write a test program that prompts the user to enter a series of integers and dis-
plays if the series contains four consecutive numbers with the same value. Your
program should first prompt the user to enter the input size—i.e., the number of
values in the series. Here are sample runs:
Enter the number of values: 8
Enter the values: 3 4 5 5 5 5 4 5
The list has consecutive fours
Enter the number of values: 9
Enter the values: 3 4 5 5 6 5 5 4 5
The list has no consecutive fours
**7.31
( Merge two sorted lists ) Write the following method that merges two sorted lists
into a new sorted list.
public static int [] merge( int [] list1, int [] list2)
 
Search WWH ::




Custom Search