Would you like to take an item? [Y]es, [N]o, or [E]xit N Next person in line!
Would you like to take an item? [Y]es, [N]o, or [E]xit E Have a good day!
Transcribed Image Text:2D Array Chart
The following String values must be stored within a 2D array called inventory. Create the 2D array with
the values from the following chart. Each cell visually represents a space for an item. X represents that
no item is currently at the location. For these locations, use "x" (lowercase) to represent empty spaces.
Provided 2D array
StuffedPython
CSalt
hAIrspray
JavaBeans
RustedMetal
SwiftShoes
FuRniture
GroovyGear
RadiantRuby
Transcribed Image Text:Name your program Giveaway.java, and it should work as follows.
Acquiring items:
Welcome the user and print: "Welcome to the 1331 Giveaway!"
Prompt and ask the user if they want to take an item: "Would you like to take an item? [Y]es,
[N]o, or [E]xit"
If the user inputs 'N' (case sensitive), print: "Next person in line!" and prompt the next
user the same prompt above. See example.
If the user inputs 'E' (case sensitive), print: "Have a good day!" and end the program
gracefully (i.e., the program ends normally without any exceptions thrown)
If the user inputs 'Y', print the current state of the giveaway 2D array and then proceed
to print: "What item are you interested in taking?"
At this point, the user should enter coordinates separated by a space where the
row should be entered first followed by the column to the item's location.
See the next section titled “Item selection" for more details.
Otherwise, if the user inputs a character outside of 'Y', 'N’, or 'E', loop until the user
inputs a proper character by prompting, "Please input 'Y', 'N’, or 'E'." followed by the
prompt "Would you like to take an item? [Y]es, [N]o, or [E]xit"
The giveaway program should be in a loop such that different users will be able to take an item
until either 'E' is inputted or there are no more items left.
Once there are no items left, instead of printing the regular prompt for Y/N/E, print: "Sorry, we
have no more items!"
The program should end gracefully afterwards.
Note: in this case, “Have a good day!" should not be printed
Item selection:
If the user input has an invalid row or invalid column, print: "Location does not exist."
Re-prompt the user "What item are you interested in taking?"
If the location inputted is empty (no item in it), print: "There is no item in this location."
Re-prompt the user "What item are you interested in taking?"
If the location inputted has an item, print: "You successfully took the [Name of the item]!"
Please be aware that we are only testing numeric input of the location in the correct format.
0 3 (correct format)
o 0,3 (incorrect format)
03 (incorrect format)
After an item has been taken, the grid containing the item should be replaced by “x". Print out
the new grid.
The program should loop back to the previous prompt, "Would you like to take an item?
[Y]es, [N]o, or [E]xit"
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.