I am having trouble completing this Plinko with functions lab. I have been working on this for a few days and feel completely stuck. The big problem that I'm running into is with the function for the menu, the other stuff is a problem too, but the menu feels like a good place to start? I can't seem to get it to "loop" through. I have been coding for just over a month now and would really appreciate some guidance on how I can complete this project.
I will include a background and the requirements below:
Here is some background about the project and the requirements:
Part 1 - Refactoring (35 points)
In particular we are expecting to see functions for:
Computing the amount of prize money won for a single chip given the slot the chip ended up in-- this function must be defined as "double ComputeWinnings(int slot) {… your code here …}. (See the original Plinko lab for the complete list of these values).
Simulating one chip falling-- you will have to use your discretion on how you name and code this, but it should make both the "Drop a single chip into one slot" option and the next function (Simulating multiple chips falling) easier to write. This function must make use of the "ComputeWinnings" function described above.
Simulating multiple chips falling-- similarly this function should make both the "Drop multiple chips into one slot" option and a new "Drop multiple chips into each slot" option (described below) easier to write. This function must make use of the "Simulating one chip falling" function described above.
Add a new menu item for "Drop multiple chips into each slot", but you do not have to implement it yet. You will implement it in Part 3.
Part 2 - Better Error Handling (30 points)
Add a function for getting the number of chips and a function for getting the slot number. Within these functions check for user input error and reprompt until the user provides valid input. You must be able to recognize erroneous input like "-1", "x", "Not even a number", and in the case of a slot number, invalid integers like "9". You may assume that there will be no real-valued inputs like "2.3". Add a function for getting the menu option also, reprompting if an erroneous option is input.
If you think about it for a minute you will realize that you could use a single function rather than three separate functions for inputting a correct integer. Obviously it would need additional parameters to work as required in each case, but it is a better approach. We encourage you to do it with just one function. More general functions like this have the advantage of being re-usable in later programs which need an integer input, rather than having to write a new function for each specific variation on inputting an integer.
Part 3 - Functions and the Power of Code Reuse (20 points)
In this part of the lab, you will take advantage of functions to add an additional menu option to your Plinko program, without having to duplicate code from the other menu options.
Add a new menu option 3 that allows the user to drop the same number of chips into each of the 9 slots. For example, if the user enters 5, you simulate dropping 5 chips into each of the 9 slots.
Prompt the user to enter one number, which is the number of chips to drop into every slot. If the number of chips is non-positive or a string, etc., reprompt until you get valid input (hint: just use the function you wrote in Part 2)
For each slot, report the total and average amount of money won for all chips dropped into that slot.
Deductions
New functions for:
Computing the amount of prize money won for one chip given the slot it ended up in (called "ComputeWinnings"). (5 points)
Simulating one chip falling (must use "ComputeWinnings"). (5 points)
Simulating multiple chips falling (must use "Simulate one chip falling"). (5 points)
New functions for menu, slot and chip input, with error handling. (5 points) It could be a single function with additional parameters as noted.
Notes
The test cases start with just the input part, so you can start there and then build your solution step by part.
Well, there's nothing in your DisplayMenu() or main() functions that does any looping, so we can't see what you've tried, which means that we can't help you understand what you did wrong, or how to fix it.
When creating a loop, you need to think clearly about three things:
1) What operations do you want to be repeated on each iteration of the loop?
2) What determines how many times the loop keeps iterating? In other words, what condition(s) do you want to cause the loop to stop iterating?
3) What conditions need to be set up at the start of the loop?
Once you've figured out those things, then it should be straightforward to figure out what code you need to write to make it happen.