Question: Exercise 2. Probabilities and Colors Write a program that randomly chooses among three different colors for displaying text on the screen. Use a loop to

 Exercise 2. Probabilities and Colors Write a program that randomly chooses

Exercise 2. Probabilities and Colors Write a program that randomly chooses among three different colors for displaying text on the screen. Use a loop to display 20 lines of text, each with a randomly chosen color. The probabilities for each color are to be as follows: white 30%, blue 10%, green 60%. Suggestion: Generate a random integer between 0 and 9. If the resulting integer falls in the range 0 to 2 (inclusive), choose white. If the integer equals 3, choose blue. If the integer falls in the range 4 to 9 (inclusive), choose green. Test your program by running it ten times, each time observing whether the distribution of line colors appears to match the required probabilities. (The Irvine32 library is required for this solution program - call ClrScr, Randomize, SetTextColor, WriteString and Crlf; refers to Ch 5/ Module 2) IMPORTANT: for this exercise, NOT allowable to use any one of these directives: IF, .ELSE, .ELSEIF

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!