Assignment #4 - 84B

# Assignment #4 - 84B

```ASSIGNMENT 4                                       DUE: 20 OCTOBER 84
------------                                    WEIGHT: 30

A THROW OF TWO DICE MAY PRODUCE ANYWHERE FROM A TWO (SNAKE-EYES) TO A
TWELVE (BOX-CARS).  WRITE A PROGRAM SYSTEM IN WATFIV TO PRODUCE THE
TABLE SHOWN BELOW.

PROBABILITY OF A
ROLL      NUMBER OF WAYS OF     PROBABILITY OF     ROLL GREATER THAN OR
VALUE     GETTING THIS ROLL    GETTING THIS ROLL    EQUAL TO THIS ROLL
-----     -----------------    -----------------   --------------------

2               1                  .028                  1.000
3               2                  .056                  0.972
.               .                    .                      .
.               .                    .                      .

12              1                  .028                   .028

FOR ANY ROLL VALUE, X, THE PROBABILITY OF GETTING THAT ROLL IS

P(ROLL=X) = TALLY(X) / 36

WHERE TALLY(X) IS THE NUMBER OF WAYS OF GETTING X.  ALSO, THE
PROBABILITY OF GETTING A ROLL GREATER THAN OR EQUAL TO X IS

P(ROLL>=X) = P(ROLL=X) + P(ROLL=X+1) + ... + P(ROLL=12)

THUS,   P(ROLL=10)  = TALLY(10)/36.0 = 3.0/36.0 = .083
AND     P(ROLL>=10) =  .083 + .056 + .028       = .167

YOUR MAIN PROGRAM SHOULD CALL A SUBROUTINE THAT COMPUTES THE NUMBER OF
WAYS TO OBTAIN EACH ROLL (THE TALLY), AND A FUNCTION THAT COMPUTES
P(ROLL=X).  YOU CAN HAVE OTHER SUBPROGRAMS IF YOU WANT, BUT THE ABOVE
SUBPROGRAMS YOU SHOULD HAVE.

AFTER YOU HAVE WRITTEN THIS PROGRAM, WRITE A SECOND PROGRAM THAT LOOKS
EXACTLY LIKE THE FIRST ONE, BUT NOW USE A FUNCTION TO COMPUTE THE TALLY
AND A SUBROUTINE TO COMPUTE P(ROLL=X).

TURN IN BOTH PROGRAMS WITH THEIR OUTPUTS (THEY WILL PRODUCE THE SAME
OUTPUT) PROPERLY LABELED.  REMEMBER TO USE MEANINGFUL VARIABLE NAMES
AND INDENTATION.
```