Question: XCode C++ Open a file called someRNG.txt for input. someRNG.txt is a text file of random numbers ranging from 1 to 100. There are 20
XCode C++
- Open a file called "someRNG.txt" for input. "someRNG.txt" is a text file of random numbers ranging from 1 to 100. There are 20 random numbers in this text file, but your code should be able to handle text files of any amount. You may download it in "Files" on Canvas
- Ask the user what the probability of winning is. You may assume that the user always enters valid whole numbers.
- Read through the text file and output the results of the event being either a win or a lose, based on the user's entered value. These results should be outputted to a text file called "simResults.txt". Note that your formatting does not need to be perfect like Canvas', but it should still reasonably match the output below.
- The program should output "Simulation Done" to the screen when finished.
Sample Output 1
What is the probability of winning? 44
Simulation Done.
simResults.txt
- Lose
- Lose
- Win
- Win
- Win
- Win
- Win
- Lose
- Win
- Lose
- Lose
- Lose
- Win
- Lose
- Lose
- Win
- Win
- Lose
- Lose
- Win
*Explanation* If the probability of winning is 44%, then the correct way to simulate this probability would be to use the numbers 1 to 44 and count them as winners, and everything else as not winning.
Sample Output 2
What is the probability of winning? 79
Simulation Done.
simResults.txt
- Win
- Win
- Win
- Win
- Win
- Win
- Win
- Win
- Win
- Win
- Lose
- Lose
- Win
- Win
- Win
- Win
- Win
- Win
- Win
- Win
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
