CSE 5910 - Sample programming test 2

Phase 1

Create an empty Wallet. The class Wallet is part of a package. The jar sample2.jar contains the code of all the classes in this package. The API of this package can be found here.

Phase 2

Extend your program by presenting the user with the following prompt.
Enter a coin:
The entry has to be made on the same line as the prompt. Also read the entered coin. You may assume that the user will enter either penny, nickel or dime. (This is a precondition of your app.)

Here is a sample run:

Enter a coin: nickel

Phase 3

Extend your program by creating a Coin that corresponds to the entry by the user and by adding it to the wallet. For example, the user enters nickel then a Nickel is created and added to the wallet.

Phase 4

Extend your program by presenting the user with the following prompt.
More coins? (y/n)
The entry has to be made on the same line as the prompt. Also read the entered reply.

Here is a sample run (including the output of previous phases and the input of the user):

Enter a coin: nickel
More coins? (y/n) y

Phase 5

Modify your program such that if the user enters y or Y (possibly with spaces before and after it), then the user is re-prompted (see sample run).

Here is a sample run (including the output of previous phases and the input of the user):

Enter a coin: nickel
More coins? (y/n)     Y
Enter a coin: dime
More coins? (y/n) y
Enter a coin: nickel
More coins? (y/n)       y
Enter a coin: penny
More coins? (y/n) n

Phase 6

Finally, extend your program by creating a Wallet that is randomly generated, adding this random wallet to the wallet you created in the previous phases, and by printing the coins of this wallet.

Here is a sample run (including the output of previous phases and the input of the user):

Enter a coin: nickel
More coins? (y/n)     Y
Enter a coin: dime
More coins? (y/n) y
Enter a coin: nickel
More coins? (y/n)       y
Enter a coin: penny
More coins? (y/n) n
*****
Penny
Dime
Dime
Penny
Penny
Penny