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.

Answers

Answer 1

INCLUDE Irvine32.inc

.data

msgIntro  byte "This is Your Name's fourth assembly extra credit program. Will randomly",0dh,0ah

        byte "choose between three different colors for displaying twenty lines of text,",0dh,0ah

        byte "each with a randomly chosen color. The color probabilities are as follows:",0dh,0ah

        byte "White=30%,Blue=10%,Green=60%.",0dh,0ah,0

msgOutput byte "Text printed with one of 3 randomly chosen colors",0

.code

main PROC

;

//Intro Message

      mov edx,OFFSET msgIntro  ;intro message into edx

      call WriteString         ;display msgIntro

      call Crlf                ;endl

      call WaitMsg             ;pause message

      call Clrscr              ;clear screen

      call Randomize           ;seed the random number generator

      mov edx, OFFSET msgOutput;line of text

      mov ecx, 20              ;counter (lines of text)

      L1:;//(Loop - Display Text 20 Times)

      call setRanColor         ;calls random color procedure

      call SetTextColor        ;calls the SetTextColor from library

      call WriteString         ;display line of text

      call Crlf                ;endl

      loop L1

exit

main ENDP

;--

setRanColor PROC

;

; Selects a color with the following probabilities:

; White = 30%, Blue = 10%, Green = 60%.

; Receives: nothing

; Returns: EAX = color chosen

;--

      mov eax, 10              ;range of random numbers (0-9)

      call RandomRange         ;EAX = Random Number

      .IF eax >= 4          ;if number is 4-9 (60%)

      mov eax, green           ;set text green

      .ELSEIF eax == 3         ;if number is 3 (10%)

      mov eax, blue            ;set text blue

      .ELSE                    ;number is 0-2 (30%)

      mov eax, white           ;set text white

      .ENDIF                   ;end statement

      ret

setRanColor ENDP


Related Questions

I need someone to explain gor me python coding!

Answers

Answer:

Explanation:

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. Python is a general purpose language, meaning it can be used to create variety of different programs and isn't specialised for any specific problems

Class B { Public: Void b1(); Protected: Void b2(); }; Class A : public B { Public: Void a1(); Protected: Void a2(); }; Class C: public A { Public: Void c1(); }; Void main () { B temp1; A temp2; C temp3; } a) Name all member functions of all classes visible through temp1 in the main function? b) Name all member functions of all classes visible through temp2 in the main function? c) Name all member functions of all classes visible through temp3 in the main function? d) Which class is the parent of class A? e) Which class is the child of class A?​

Answers

Answer:

write the questions a little clear we can't read it

how do you copy a file​

Answers

Answer:

right click and press control c

which computer are used by mobile employees as Meter readers.​

Answers

Explanation:

handheld computers

Some handheld computers have miniature or specialized keyboards. Many handheld computers are industry-specific and serve the needs of mobile employees, such as meter readers and parcel delivery people, whose jobs require them to move from place to place.

Who innovated an aeroplane? ​

Answers

Answer:

White brothers!!

Explanation:

so in media literacy,
what roles do confirmation bias, stereotyping, and other cognitive biases impact how we interpret events, news, and information? ​

Answers

Answer:

Confirmation biases impact how we gather information, but they also influence how we interpret and recall information. For example, people who support or oppose a particular issue will not only seek information to support it, they will also interpret news stories in a way that upholds their existing ideas.

computer in education are used for teaching and learning aids​

Answers

i think the answer is 9 but my head really hurt so i’m not sure

fill in the blank with the correct response

Answers

Answer:

regenerates

Explanation:

a hub regenerates it's signal bit by bit as it travels down the physical medium

collection of any data can be database
False
True​

Answers

Answer:

True is the answer

have a great day

Which one is the result of the ouWhen you move a file to the Recycle Bin, it will be immediately deleted from your computer.

A. True

B. Fals

Answers

Answer:

B => false

Explanation:

it just keep it on recycle bin => not being removed

False

Explaination :

The deleted file will stay in Recycle Bin for a short period of time before it's permanently deleted from your computer

will social media lose its relevance?​

Answers

Judging from it's prevalence and popularity, there will be a long way to go until people start to lose interest with expressing themselves online. So no, social media will not lose its relevance, but maybe when technology is dead, then it will.

They are correct? thank you!

Answers

Answer:

[OPINION]

First one is correct.

For the second one, I think the leader should accept the invitation and forward it to the entire team. [As the team experienced success due to group work, so every team member should be invited... as the success was a result of the hardwork of every member]

About the third one, I think it depends on the person so you may be correct. But, if I was asked to choose I would have been chosen.... rational approach

This is just my opinion. Hope it helps you:)

Kith Smallest Number Real World Example

Hello!

What are five reasons why one would need to find the kth smallest number of an array? Also known as the Selection Problem.

I'm looking for 5 real world examples.

Will definitely give brainliest!


The Selection Problem is a problem where we must find the kth order statistic of a given array. As in, we must find the largest kth number. For example, if our array is [1, 3, 4, 5, 9], and k = 3, we would want to find the 3rd largest number, so our algorithm should output the number 4.

Answers

Answer:

A new coffee shop is being built. Its location is the reflection of the arcade's coordinates across

the y-axis. Which procedure will find the correct distance between the arcade and the new coffee shop

Write a Visual Basic Program to display factorial series upto nth term 1! 2! 3! 4! ...!

Answers

Answer:

n = n(n-1)!

Explanation:

expanding the factorial we get;

1!=1.

2!=2x1.

3!=3x2x1.

4!=4x3x2x1.

5!=5x4x3x2x1.

we can rewrite the above factorials as:

1!=1

2!=2!

3!=2!x3

4!=4x3!

5!=5x4!

the pattern applies such that if we have n th number we get it's factorial as;

n = n(n-1)!

viết chương trình hoàn chỉnh các yêu cầu sau:
a. Định nghĩa hàm có tên là PSTG(), có hai tham số kiểu nguyên x và y hàm trả về giá trị phân số x/y ở dạng tối giản.
b. Gọi hàm đã định nghĩa ở trên trong hàm main () để in lên mà hình một phân số x/y ở dạng tối giản, với x và y được nhập từ bàn phím.

Answers

Explanation:

the perimeter of an aluminium sheet is 120 CM if its length is reduced by 10% and its breadth is increased by 20% the perimeter does not change find the measure of the length and the breadth of the sheet

In what tab can a user find the workspace option?

Answers

D. View.
You can find the workspace and preview of the file in View.

why is Touchpad used in the laptop computer​

Answers

Answer:

in controlling the mouse or cursor

Explanation:

as is it known tha a cursor is a poniting device. and the only way to control it without a mouse is the touchpad

Suppose you and four of your friends are wirelessly connected with the home wireless router. [03] At this moment router is not transmitting data to the outgoing link and all of you want to browse internet and send packets of same size to the router. Consider the bandwidth of the outgoing link is20Mbps , packet size is 2500 bytes and the processing delay of each packet is
2μs . If your packet is queued at position eleven, calculate the delay after which your packet will be transmitted

Answers

format please? i cant understand

1011111 ÷ 11 in numerical​

Answers

Answer:

91919.18182

Explanation:

Answer:

91,919 .1

HOPE IT HELPS .

Suppose a Huffman tree is to be built for 5 characters. Give a set of 5 characters, and their distinct probabilities (no duplicates), that would result in the tallest possible tree. Show the tree. Derive the average code length: write the expression, you don't have to simplify it down to a single value.

Answers

I love chipotle do you live chipotle

What is the output of this Python program, if the user types 3 as input?

Answers

0 1 2 will be the output of the function

How teachers apply stenhouse theory

Answers

Answer:

In curriculum, a vision of knowledge, the role of the educator and a concept of the process of education are all present. In this sense, Stenhouse suggests that the role of teachers and professors is fundamental in the elaboration and implementation of curriculum.

Write a recursive function stringReverse that takes a string and a starting subscript as arguments, prints the string backward and returns nothing. The function should stop processing and return when the end of the string is encountered. Note that like an array, the square brackets ( [ ] ) operator can be used to iterate through the characters in a string.

Answers

Answer:

void stringReverse(string s, int start){

   if(s[start]=='\0'){

       return;

   }

   else{

       stringReverse(s.substr(1,s.length()-1),start+1);

       cout<<s[start];

   }

}

Explanation:

3 type of keyboarding

Answers

Answer:

Mechanical Keyboards, Wireless Keyboards and Projection Keyboards

Explanation:

hope it helps

What is touch pad ? Computer class four

Answers

Answer:

A touch pad is an input device used for pointing on a computer display screen.

For the following scenario, indicate whether the action is a good practice or bad practice to safeguard your personally identifiable information.
Marina's personal computer requires a password to get access.

Answers

Answer:

This is most definitely a good practice to safeguard personal information. This way, people wouldn't be able to access her computer easily, since it requires a code that only she would know. of course, there is the possibility that someone can just guess or hack into her computer, but that's why computers usually have you create a unique code that consists of uppercases, lowercases, numbers, special characters, etc which would be difficult to guess. it's a good protection for anyone who wants to safely keep their personal information from everyone else.

Input two numbers and work out their sim, subtraction, multiplication, division, remainder, average and sum of the squares of the numbers.

Answers

def ultimate_math (num1, num2):

try:

array_num = [num1, num2]

print (num1 + num2)

print (num1 - num2)

print (num1 * num2)

print (num1 / num2)

print (num1 % num2)

print ((num1 + num2) / (len(array_num)))

print ((num1**2) + (num2**2))

except ValueError:

return "Invalid Input"

user_num1 = float (input (" Please enter a num: "))

user_num2 = float (input (" Please enter a second num: "))

print (ultimate_math (user_num1, user_num2))

consider a hard disk with the following specifications :
3.5 in diameter

Answers

Answer:

usable capacity = 10 GB

Number of cylinders = 256

Block size = 4 KB

(1)Bytes in each cylinder = (10*230)/(256) = (10*222) = 40 MegaBytes

(2)Number of Blocks in each cylinder = (10*222)/(212) = 10K

(3)capacity of one track = 40 MegaBytes/(10*2) = 2 MB

Rotation speed = 3840 RPM

Number of rotations per second = 3840/60 = 64

Transfer rate = (2*64) = 128 MB/sec

Explanation:

What is the different type of secondary memory of a computer system.? explain

Answers

Explanation:

Solid state storage devices

optical storage devices

magnetic storage devices

what dose the following tool's do?
1-caption
2-back color
3-font
4-alignment​

Answers

Caption:it is used to display speaker's name and describe relevant sounds that are inaccessible to people of hard hearing or who are deaf

Back color: it is used to fill a section's interior. it contains numerical expressions that corresponds

Font: it is used to add style to a document or webpage

Alignment: it is used to describe how text is placed on a screen.

If you like my answer,mark as brainliest

Other Questions
make x the subject of the formulashow your working. The angle of elevation to the top of theschool is 37 from where you are standing11.2 m from the wall of the school. Findthe height of the school. which element is the most important element of our society why 'Development of the society is a universal process'.Justify the statement. the enemy won because of their ____ numberA. senior B. superior C. upper D. all are correct Nahuatl is the language spoken by the Nahua ethnic group that is found today in Mexico, but with deep historical roots. You might know one Nahua group: the__________________, more accurately called the Mexica. The Mexica were one of many Mesoamerican cultural groups that flourished in Mexico prior to the arrival of Europeans in the sixteenth century. What was the Significance of the Iroquois league? verify whether the point (2,5) lies on 2x -y+1=0 or not .Presidential Impeachments1869: Andrew Johnson1998: Bill Clinton 2019: Donald Trump 2021. Donald Trump.Which of constitutional principle is represented by the events shown here?A)republicanismB)individual rightsOchecks and balancesD)separation of powers151 logical fallacy Well, what form of government do you want, a government by liberal do-gooders ready to spend your hard-earned dollars or a government led by business minds that understand how to live within a tight budget and generate jobs that put people to work. Group of answer choices Question 21 of 25What is g(x)?10-5-10-55-5--10A. g(x) = -1XB. g(x) = -x2C. g(x) = -2*D. g(x) = -xSIDST how can the welfare of all human be possible Ag,Au and Cu are called coinage metals why plzzzz hurry its urgent plzzz Lucas and his brother___(bring) to the amusement park thisafternoon. What body part is she describing?El hombroEl cuelloLa manoLa nariz a 4 pint carton of frozen yogurt costs 6.08 what is the price per cup HELP MEEE THIS IS 38 points because I need help wit 3 questions 2. if my granny ( be ) younger , she ( not forget ) so many things3. William is such a naught boy ! if he ( do ) that again , i (get) angry with him!4 if i ( have ) more noney , i ( buy) a house. i wish i had more money!5 if Kate (not tell) him anything , he (never / find out) . Now it's too late !6 Robert and Harry (not know) the truth if we ( not tell) them . Let's keep the secret!7. I ( help) you with your project if you ( ask) me , but since yo didn't say a word , now it's too late !8. I'm thinhking of cleaning the windows later . (you /give ) me a hand if i (need) your held?9. Helen ( work) harder, she ( get ) promoted , but she's a very lazy person 10. you ( not feel ) so tired if you ( sleep) more . you should go to bed earlier the mass of an object is 45 kg and it has a density of 5 gram per centimetre cube what is the volume why do so few people live in sahara desert of North Africa