Sie sind auf Seite 1von 1

Assignment 2

Q1: Write a program that creates a LinkedList object of 10


characters, then creates a second LinkedList object containing a
copy of the first list, but in reverse order.
Q2: Write a program that inserts 25 random integers from 0 to
100 in order into a LinkedList object. The program should sort the
elements, then calculate the sum of the elements and the
floating-point average of the elements.
Q3: Write a program that determines and prints the number of
duplicate words in a sentence. Treat uppercase and lowercase
letters the same. Ignore punctuation.
Q4: Write a program which creates a concordance of characters
occurring in a string (i.e., which characters occur where in a
string). Read the string from the command line. Use HashMap to
store each character along with list of places where it occurs.
Running the program:
>java Concordance Hello World
{d=[9], o=[4, 6], r=[7], W=[5], H=[0], l=[2, 3, 8], e=[1]}

Das könnte Ihnen auch gefallen