Java Reference
In-Depth Information
2. Write a method that takes as input a StringBuffer and reverses it. For example, if
the input string is abc , then the method will change the string to cba . The method
should have void return type.
3. Write a method that takes in an ArrayList of Integer and an integer and returns
true if the integer is in the ArrayList and false otherwise.
4. Write a program that prints five random playing cards, where all cards must be
different. Example output is: “queen of spades”, “ten of clubs”, “three of diamonds”,
“five of hearts”, “seven of spades”. Use the enum construct for both the value and suit
of the card. The value of a card can be: “two”, “three”, “four”, “five”, “six”, “seven”,
“eight”, “nine”, “ten”, “Jack”, “Queen”, “King”, or “Ace”. The suit of a card can be
“spades”, “hearts”, “diamonds”, or “clubs”. Store the cards in an ArrayList .Before
inserting a new card in the ArrayList , ensure that the card is not already in the list.
5. Write a method that takes as input an ArrayList of integers. The methods should
reverse the elements and have void return type.
6. Write a method that takes as input an ArrayList of integers. The methods should
return an ArrayList of integers that contains the three consecutive integers in the
input ArrayList with the biggest sum.
7. Write a method that takes as input an ArrayList of doubles. The method should
return an ArrayList of the doubles that are at even positions (i.e., position 0, 2, 4,
and so on).
8. Write a method that takes as input two ArrayList s of integers. The method should
return true when the ArrayList s have at least one element in common and false
otherwise.
7.10 Lab
Create a phone book program. Add capabilities for inserting a new name and phone
number, deleting a person from the directory, searching for the phone number of a person,
and reverse lookup (i.e., searching for a name by phone number). Create a Person class and
an ArrayList of people as part of the implementation.
7.11 Project
Pig Latin is a twist of English for people who want to be silly, or for kids who do not
want their parents to know what they are talking about. There are different ways in which
people speak pig Latin. For this project, we are going to use the following dialect. For words
that begin with a single consonant, take the consonant off the front of the word and add it
to the end of the word. Then add “ay” after the consonant. Here are some examples.
 
Search WWH ::




Custom Search