subject

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 to 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.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:00
Digital information is stored using a series of ones and zeros. computers are digital machines because they can only read information as on or off –1 or 0. this method of computation is known as the system
Answers: 1
question
Computers and Technology, 22.06.2019 14:30
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
question
Computers and Technology, 23.06.2019 04:31
This graph compares the cost of room and board at educational institutions in texas.
Answers: 1
You know the right answer?
Write a program that randomly chooses among three different colors for displaying text on the screen...
Questions
question
Mathematics, 27.09.2020 21:01
question
Mathematics, 27.09.2020 21:01
question
Mathematics, 27.09.2020 21:01
question
Mathematics, 27.09.2020 21:01
question
Mathematics, 27.09.2020 21:01
Questions on the website: 13722367