answer.
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]
2 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]2 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
A three-point bending test was performed on an aluminum oxide specimen having a circular cross section of radius 3.5 mm (0.14 in
RideAnS [48]

To resolve this problem we have,

R=3.5mm\\F_f1=950N\\L_1=50mm\\b=12mm\\L_2=40mm

F_{f2} is unknown.

With these dates we can calculate the Flexural strenght of the specimen,

\sigma{fs}=\frac{F_{f1}L}{\pi R^3}\\\sigma{fs}=\frac{(950)(50*10^{-3})}{\pi 3.5*10^{-3}}\\\sigma{fs}=352.65Mpa

After that, we can calculate the flexural strenght for the square cross section using the previously value.

\sigma{fs}=\frac{F_{f2}L}{\pi R^3}\\(352.65*10^6)=\frac{3Ff(40*10^{-3})}{2(12*10^{-10})}\\F_{f2}=\frac{352.65*10^6}{34722.22}\\F_{f2}=10156.32N\\F_{f2}=10.2kN

6 0
2 years ago
If water molecules pass through a membrane with a steady state flux of 220 mole/(m2 day), how long will it take, in hours, for 0
goblinko [34]

Answer:

<em>0.0386 hr</em>

<em></em>

Explanation:

Area = 565 cm^2 = 0.0565 m^2  (1 cm^2 = 0.0001 m^2)

flux state rate = 220 mole/m^2-day

<em>There are 24 hrs in a day,</em> therefore rate in hrs will be

220/24 = 9.17 mole/m^2-hr

mass of water = 0.4 kg

molar mass of water = (1 x 2) + 16 = 18 kg/mole

therefore,

<em>mole of water = mass of water/molar mass of water</em>

mole of water = 0.4/18 = 0.02 mole

<em>mole flux = mole/area</em> = 0.02/0.0565 = 0.354 mol/m^2

<em>time that will be taken will be for water to pass = mole flux/mole flux rate</em>

time = 0.354/9.17 = <em>0.0386 hr</em>

7 0
2 years ago
A steel rotating-beam test specimen has an ultimate strength Sut of 1600 MPa. Estimate the life (N) of the specimen if it is tes
ziro4ka [17]

Answer:

the life (N) of the specimen is 46400 cycles

Explanation:

given data

ultimate strength Su = 1600 MPa

stress amplitude σa = 900 MPa

to find out

life (N) of the specimen

solution

we first calculate the endurance limit of specimen Se i.e

Se = 0.5× Su   .............1

Se = 0.5 × 1600

Se = 800 Mpa

and we know

Se for steel is 700 Mpa for Su ≥ 1400 Mpa

so we take endurance limit Se is = 700 Mpa

and strength of friction f  = 0.77 for 232 ksi

because for Se 0.5 Su at 10^{6} cycle = (1600 × 0.145 ksi ) = 232

so here coefficient value (a) will be

a = \frac{(f*Su)^2}{Se}    

a = \frac{(0.77*1600)^2}{700}  

a = 2168.3 Mpa

so

coefficient value (b) will be

a = -\frac{1}{3}log\frac{(f*Su)}{Se}

b =  -\frac{1}{3}log\frac{(0.77*1600)}{700}

b = -0.0818

so no of cycle N is

N =  (\frac{ \sigma a}{a})^{1/b}

put here value

N =  (\frac{ 900}{2168.3})^{1/-0.0818}

N = 46400

the life (N) of the specimen is 46400 cycles

5 0
2 years ago
A 227 pound compressor is supported by four legs that contact the floor of a machine shop. At the bottom of each leg there is a
Ganezh [65]

Answer:

1.312 in

Explanation:

Data provided in the question:

Weight of the compressor, W = 227 pound

Number of legs = 4

Maximum pressure = 42 psi

Now,

Let F be the force taken by the legs

Therefore,

W = 4F

or

227 pound = 4F

or

F = 56.75 pounds

Also,

Force = Pressure × Area

or

56.75 pounds = 42 psi × πr²                      [ r is the diameter of one leg]

or

r² = 0.4301

or

r = 0.656

therefore,

diameter = 2r = 2 × 0.656

= 1.312 in

6 0
2 years ago
Race conditions are possible in many computer systems. Consider an online auction system where the current highest bid for each
kumpel [21]

Answer:

See attached picture.

Explanation:

5 0
2 years ago
Other questions:
  • A cylindrical drum (2 ft. dia ,3 ft height) is filled with a fluid whose density is 40 lb/ft^3. Determine (a. the total volume o
    10·1 answer
  • A circular ceramic plate that can be modeled as a blackbody is being heated by an electrical heater. The plate is 30 cm in diame
    15·1 answer
  • You want to determine whether the race of the defendant has an impact on jury verdicts. You assign participants to watch a trial
    9·1 answer
  • Air in tankBis at 200 kPa, 280 K and mass 1 kg. It is connected to an empty piston/cylinder with a float pressure of 400 kPa sim
    6·1 answer
  • Add a calculated field named AccountTime that calculates the number of days each client's accounts have been open. Assume today'
    6·1 answer
  • Which one of the following activities is not an example of incident coordination
    15·1 answer
  • Argon contained in a closed, rigid tank, initially at 33.7°C, 2.1 bar, and a volume of 4.2 m3, is heated to a final pressure of
    12·1 answer
  • A three-phase line has an impedance of 0.4 j2.7 ohms per phase. The line feeds two balanced three-phase loads that are connected
    9·1 answer
  • The u velocity component of a steady, two-dimensional, incompressible flow field is u = 3 ax 2 - 2 bxy, where a and b are consta
    6·1 answer
  • The typical Canadian worker is able to produce 100 board feet (a unit of measure) of lumber or 1000 light bulbs per year. The wo
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!