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
aleksklad [387]
3 years ago
7

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

ines 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.
Computers and Technology
1 answer:
Len [333]3 years ago
7 0

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
The system should enable the staff of each academic department to examine the courses offered by their department, add and remov
Ganezh [65]

Answer:

See attached picture.

Explanation:

See attached picture.

3 0
3 years ago
Provide examples of how information technology has created an ethical dilemma that would not have existed before the advent of I
Kamila [148]
Hrhdhhdhdjhdhcnbcgfgbsbnenwnsn

7 0
3 years ago
Based on the following quote from Leonardo Da Vinci, what would be his definition of a fine artist? “Principles for the Developm
zvonat [6]

Answer:

A fine artist is one who sees the things other don't see and make connections other don't make.

7 0
3 years ago
Read 2 more answers
Help me pleaseeee!!!!!
belka [17]

Answer:

15 unit square

Explanation:

7 0
3 years ago
Read 2 more answers
Calculator is an example of
Shalnov [3]

D. digital

Explanation:

I hope it helps you

7 0
3 years ago
Other questions:
  • When using a graphics editing program, which option allows you to adjust the space around an image?
    15·1 answer
  • Attempting to determine a password that is not known to the attacker is often called ____.
    13·1 answer
  • Write a program that displays the values in the list numbers in ascendingorder sorted by the sum of their digits.
    8·1 answer
  • The number of semi skilled workers in an industry find themselves out of work, when improvements in technology render their jobs
    15·1 answer
  • Why is it unlawful for an employer to refuse to employ someone based solely on their gender without evidence that such a charact
    9·1 answer
  • Solver: Most of this class has already been written. Complete the solveRecurse() method using the backtracking. Also complete th
    10·1 answer
  • What is a systems development life cycle?
    5·1 answer
  • 1. Define what grasslands are ?
    14·2 answers
  • Which command group on the Slide Master tab is used to add headers, footers, and other placeholders to the slide
    13·2 answers
  • Networks, partnerships, and joint ventures are an example of
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!