Question: For this assignment, you will replace the paper username log with a program that will store the usernames of players who find the geocache. Write
For this assignment, you will replace the paper username log with a program that will store the usernames of players who find the geocache. Write a program that will add a player's username to a geocache log This will be part of a larger geocaching program, so only a few functions are required. You can assume that other programmers will complete the other parts of the geocaching application.
The main Function
In the main function, perform the following tasks:
ask the for username and store it in a variable
create an array of size and fill each position with the string "empty"
ask the user to identify the item found. If the item is equal to "original can of beans", then call the getSize function. Store the return value in a variable called arraySize.
If the arraySize variable is not call the addUsername function and pass the array, the arraySize variable, and username variable as arguments.
The getSize Function
The getSize function will return the number of array positions that hold usernames. Using a loop, count the number of array positions that do not hold the value "empty". If there are no positions that contain the string "empty", then the array is full, so display the error message "original can of beans destroyed by a lawn mower" and return otherwise, return the count.
The addUsername Function
The addUsername function will add a username to an array. This function requires three parameters:
username
array
arraySize variable
This function should only have one line of code. Add the username to the array in the arraySize position.
The displayUsernames Function
The displayUsernames function should use a loop to display all array positions that do not contain the word "empty".
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
