Question: Write a C++ program that calculates the probabilities of four different scenarios. You will get the input from a file named .txt that contains three

Write a C++ program that calculates the probabilities of four different scenarios. You will get the input from a file named .txt that contains three different values on each line, separated by the ',' character. The values represent the number of colored balls in a box. The first value is the number of red balls, then the number of white balls, and lastly, the number of black balls. You should have at least four test cases in your text file.

Your program should read the command line to get the input filename - .txt - that follows the flag "-i". It should also check to see if there is a "-c" to output the results to the console, or a "-f" to output the results to a file of the name .out.txt .

You are determine the probabilities of the following four situations:

1. The probability of drawing two red balls in a row (without replacement)

2. The probability of drawing a red ball and then a black ball (without replacement)

3. The probability of drawing three red balls (without replacement)

4. The probability of drawing first a white ball, then a red ball, and then a black ball (assuming that all balls are replaced before the next draw).

Format your output data in readable format

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!