header

Lab 2

Write a program that simulates the children's game called "My Grandmother's Trunk". In this game, the players sit in a circle and each player, in turn, recites the contents of the trunk (which is initially empty) in order and then names a new item. As the list grows longer it is harder and harder to remember what all is in the trunk. A player who makes a mistake must drop out and the last player in the game wins.

Simulate five turns of this game. For each turn, prompt the user to enter the name of an object to be placed into the trunk and then display the contents of the trunk. Here is a sample run of the program:

Enter name of item: hammer
My grandmother's trunk contains a hammer.
Enter name of item: toothbrush
My grandmother's trunk contains a hammer and a toothbrush.
Enter name of item: hair brush
My grandmother's trunk contains a hammer and a toothbrush and a hair brush.
Enter name of item: screwdriver
My grandmother's trunk contains a hammer and a toothbrush and a hair brush and a screwdriver.
Enter name of item: tire iron
My grandmother's trunk contains a hammer and a toothbrush and a hair brush and a screwdriver and a tire iron.

The terminal window won't be wide enough to always show the entire list of contents but you can use the horizontal scrollbar to view it all.

Submitting Your Work

Following the usual pattern, the project folder and the program file should both be named "Lab02". Submit the 'Lab02.java" file to me as an attachment to an email message whose subject is "Lab02".