1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nadya68 [22]
3 years ago
8

Write a program that randomly chooses between three different colors for displaying text on the screen. Use a loop to display tw

enty 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%. Hint: generate a random integer between 0 and 9. If the resulting integer is in the range 0-2, choose white. If the integer equals 3, choose blue. If the integer is in the range 4-9, choose green.
Engineering
1 answer:
11Alexandr11 [23.1K]3 years ago
6 0

Answer:

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

You might be interested in
Why do giant stars become planetary nebulas while supergiant stars become supernovas when their nuclear fusion slows and is over
sashaice [31]

The reason why giant stars become planetary nebulas is  Supergiant stars do not have enough mass to generate the gravity necessary to cause a planetary nebula.

<h3>Why do giant stars become planetary nebulae?</h3>

A planetary nebula is known to be formed or created by a dying star. A red giant is known to be unstable and thus emit pulses of gas that is said to form a sphere around the dying star and thus they are said to  be ionized by the ultraviolet radiation that the star is known to releases.

Learn more about  giant stars from

brainly.com/question/27111741

#SPJ1

3 0
2 years ago
A barometer reads a height of 78 cmHg. Express this atmospheric pressure to:
Yakvenalex [24]

  • A barometer reads a height of 78 cmHg. Express this atmospheric pressure to \large\mathsf{\red{\underline{Pascal(pa)}}}
7 0
3 years ago
Read 2 more answers
A reservoir is 1 km wide and 10 km long and has an average depth of 100m. Every hour, 0.1% of the reservoir's volume drops throu
Ksju [112]

Answer:

250.7mw

Explanation:

Volume of the reservoir = lwh

Length of reservoir = 10km

Width of reservoir = 1km

Height = 100m

Volume = 10x10³x10³x100

= 10⁹m³

Next we find the volume flow rate

= 0.1/100x10⁹x1/3600

= 277.78m³/s

To get the electrical power output developed by the turbine with 92 percent efficiency

= 0.92x1000x9.81x277.78x100

= 250.7MW

7 0
3 years ago
Urgent please help me...
Pepsi [2]
Scuze , am incercat , dat chiar nu stiu. Prefer sa nu raspund si sa scriu asta decat sa raspund gresit.❤️
7 0
3 years ago
4. A banking system provides users with several services:
VLD [36.1K]

A diagram showing a use case diagrams for these requirements is given in the image attached.

<h3>What is system Case diagram?</h3>

A use case diagram is known to be a kind of graphical illustration of a users in terms of their various possible association or interactions within any given system.

A use case diagram in banking can be used to prepare, depict and also to know all the functional requirements of the banking system.

Therefore, Give the use case specification for the banking system services and paying a bill online is given in the image attached.

Learn  more about Case diagram from

brainly.com/question/12975184

#SPJ1

4 0
2 years ago
Other questions:
  • To make 1000 containers of ice cream you need: 600 gallons of milk, 275 gallons of cream, and 120 gallons of flavor. Each ingred
    12·1 answer
  • Find the equivalent impedance Zeq seen by the source when Vs = 2 cos (5t) v, C = 0.2 F, R = 1 Ω and L = 0.1 H. (Give angles in d
    12·1 answer
  • Draw an ERD for each of the following situations. (If you believe that you need to make additional assumptions, clearly state th
    15·1 answer
  • How does flextape adhere under water?​
    8·1 answer
  • Home safety and security is an _________<br><br> process. (7 Letters)<br><br> Answer
    10·1 answer
  • .If aligned and continuous carbon fibers with a diameter of 6.90 micron are embedded within an epoxy, such that the bond strengt
    11·1 answer
  • Moonbeam-Musel (MM), a manufacturer of small appliances, has a large injection molding department. Because MM's CEO, Crosscut Sa
    13·1 answer
  • Please help me on this it’s due now
    14·1 answer
  • A kitchen contains one section of counter that's 20 inches
    7·1 answer
  • From the list of problems below, check all that are known to be NP-complete. You do not need to justify your answer. (Set cover)
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!