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++

  1. 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
  2. Ask the user what the probability of winning is. You may assume that the user always enters valid whole numbers.
  3. 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.
  4. 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

  1. Lose
  2. Lose
  3. Win
  4. Win
  5. Win
  6. Win
  7. Win
  8. Lose
  9. Win
  10. Lose
  11. Lose
  12. Lose
  13. Win
  14. Lose
  15. Lose
  16. Win
  17. Win
  18. Lose
  19. Lose
  20. 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

  1. Win
  2. Win
  3. Win
  4. Win
  5. Win
  6. Win
  7. Win
  8. Win
  9. Win
  10. Win
  11. Lose
  12. Lose
  13. Win
  14. Win
  15. Win
  16. Win
  17. Win
  18. Win
  19. Win
  20. Win

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!