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
Water is leaking out of an inverted conical tank at a rate of 11700.0 cubic centimeters per min at the same time that water is b
Anastaziya [24]

Answer:

V'_{in}=136,922.92cm^{3}/min

Explanation:

In order to solve this problem, we must start by drawing the situation so we can see what the problem is about. (See attached picture)

So, since the problem wants us to write our answer in centimeters per minute, we can start by converting each of the meters to centimeters,so we get:

5m*\frac{100cm}{1m}=500cm

14m*\frac{100cm}{1m}=1400cm

2.5m*\frac{100cm}{1m}=250cm

Next, the volume of a cone can be found by using the following formula:

V=\frac{1}{3} \pi r^{2}h

In this case, both the radius and the height will be constantly changing, so we will need to find an equation to relate the height with the radius. We can find it by analyzing the cross section of the cone, which makes a right triangle. By using similar triangles we get:

\frac{h}{r}=\frac{1400}{250}

when solving for r we get that:

r=\frac{250}{1400} h

which simplifies to:

r=\frac{5}{28} h

so now, we can substitute this on our volume equation so we get:

V=\frac{1}{3} \pi (\frac{5}{28}h)^{2}h

which simplifies to:

V=\frac{25}{2352}\pi h^{3}

now we can take the derivative of that equation so we get:

\frac{dV}{dt}=\frac{25}{784}\pi h^{2} \frac{dh}{dt}

and now we can substitute:

\frac{dV}{dt}=\frac{25}{784}\pi (250cm)^{2} (20cm/min)

which solves to

\frac{dV}{dt}=125,222.92\frac{cm^{3}}{min}

this will represent the total amount of water that is being kept inside the tank. Now we can calculate the amount of water that is entering the tank.

V'_{in}-V'_{out}=V'_{tot}

so:

V'_{in}=V'_{tot}+V'_{out}

V'_{in}=125,222.92cm^{3}/min+11,700cm^{3}/min

V'_{in}=136,922.92cm^{3}/min

7 0
3 years ago
What are the four categories of engineering materials used in manufacturing?
alexgriva [62]

Answer:

metals, composite, ceramics and polymers.

Explanation:

The four categories of engineering materials used in manufacturing are metals, composite, ceramics and polymers.

i) Metals: Metals are solids made up of atoms held by matrix of electrons. They are good conductors of heat and electricity, ductile and strong.

ii) Composite: This is a combination of two or more materials. They have high strength to weight ratio, stiff, low conductivity. E.g are wood, concrete.

iii) Ceramics: They are inorganic, non-metallic crystalline compounds with high hardness and strength as well as poor conductors of electricity and heat.

iv) Polymers: They  have low weight and are poor conductors of electricity and heat

8 0
3 years ago
50. You are not permitted to work on any equipment or machinery at any time if the
dexar [7]
I assume this is a wood shop question:

You may not work on any equipment if the TEACHER is not present in the room.
7 0
4 years ago
For some transformation having kinetics that obey the Avrami equation , the parameter n is known to have a value of 1.1. If, aft
ivanzaharov [21]

Answer:

total time  = 304.21 s

Explanation:

given data

y = 50% = 0.5

n = 1.1

t = 114 s

y = 1 - exp(-kt^n)

solution

first we get here k value by given equation

y = 1 - e^{(-kt^n)}   ...........1    

put here value and we get

0.5 = 1 - e^{(-k(114)^{1.1})}    

solve it we get

k = 0.003786  = 37.86 × 10^{4}

so here

y = 1 - e^{(-kt^n)}

1 - y  =  e^{(-kt^n)}

take ln both side

ln(1-y) = -k × t^n  

so

t = \sqrt[n]{-\frac{ln(1-y)}{k}}    .............2

now we will put the value of y = 87% in equation  with k and find out t

t = \sqrt[1.1]{-\frac{ln(1-0.87)}{37.86*10^{-4}}}

total time  = 304.21 s

7 0
3 years ago
A cyclone is operated in a closed circuit with a ball mill. The cyclone is feed from a rod mill with a slurry that has a density
pav-90 [236]
Here is the flow sheet. Hope this helps have a great day!!

3 0
3 years ago
Other questions:
  • What are the three main areas of bioengineering?
    11·1 answer
  • Inventions for a 9 year old​
    15·1 answer
  • Technician A says a "dry park check" is a good way to check ball joints and control arm bushings for looseness. Technician B say
    15·2 answers
  • For problems 1 and 2, six luminaires, similar to Style E used in the Commercial Building, are to be installed in a room that is
    13·1 answer
  • Match each situation with the type of material (conductor or inductor) you would want to use in it. You need to connect a recent
    15·1 answer
  • Explain why you chose the final design of your prototype and how it solved the identified need
    9·1 answer
  • THE COMPUND INTEREST ON RS 30,000AT 7% PER ANNUM IS RS 4347 THE PERIOD IN YEARS
    7·2 answers
  • A 12 kg hockey puck is traveling at a velocity of 15 m/s. What is the momentum?
    7·1 answer
  • Drivers education :Anything that draws your mind off driving is
    9·1 answer
  • Which type of astm c150 standard portland cement is best suited for a concrete where minimal total heat evolution and minimal ra
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!