Assignment #5 - 84B

# Assignment #5 - 84B

```                           ASSIGNMENT 5
WEIGHT: 30
DUE: 10 NOVEMBER 84

BESIDES USING THE COMPUTER TO COMPUTE LIST OF VALUES, ONE CAN ALSO
USE THE COMPUTER TO PLOT THE VALUES IN GRAPHICAL FORM.  THE GRAPH WILL
CONSIST OF DOTS "...." FOR THE AXES AND A CROSS "X" FOR EACH COMPUTED
POINT (X,Y) OF THE GRAPH.  BY PLOTTING A SUFFICIENT NUMBER OF POINTS OF
THE GRAPH, WE OBTAIN A PICTURE OF THE GRAPH.  THE ALGORITHM IS GIVEN
BELOW.

OUR GRAPHS WILL CONSIST OF 81 LINES AND EACH LINE WILL CONTAIN
101 CHARACTERS (' ', '.' OR 'X').  WE CHOOSE THE HORIZONTAL AXIS AS THE
Y-AXIS AND THE VERTICAL AXIS AS THE X-AXIS.  SINCE EACH VALUE OF X GIVES
A UNIQUE VALUE OF Y, WE CAN CALCULATE AND PLOT OUR GRAPH ONE LINE AT A
TIME. CONSEQUENTLY, WE WOULD REQUIRE ONLY A LINEAR ARRAY WITH 101 CELLS.

ASSUMING WE ALWAYS WANT TO PLOT OUR FUNCTIONS FOR -4.0 <= X <= 4.0,
AND THE RANGE OF Y FOR THESE VALUES ALWAYS LIE BETWEEN -50.0 AND 50.0,
THEN WE HAVE THE FOLLOWING STEPS:

1. SET X EQUAL TO ITS MINIMAL VALUE
2. FIND THE CORRESPONDING VALUE OF Y
3. SCALE THE VALUE OF Y TO AN INTEGER J BETWEEN 1 AND 101
-->  HERE, WE ARE GIVEN THAT Y LIES BETWEEN -50
AND 50.  ADDING 51 TO Y AND ROUNDING OFF
THE RESULT WILL GIVE A POSITIVE INTEGER
BETWEEN 1 AND 101.
4. PRINT A LINE WITH A CROSS(X) IN COLUMN J OF THE GRAPH
-->  REMEMBER TO PRINT A DOT FOR THE COLUMN
WHICH REPRESENTS THE X-AXIS, AND TO PRINT
A WHOLE LINE OF DOTS WHEN THE LINE REPRESENTS
THE Y-AXIS.
5. INCREMENT THE VALUE OF X BY ((4.0 - (-4.0)) / 80)AND
REPEAT STEPS 1-4 AS LONG AS X DOES NOT EXCEED ITS
MAXIMUM VALUE.

THE FUNCTIONS YOU WILL HAVE TO PLOT IN THIS ASSIGNMENT WILL BE
OF THE FORM :
3     2     1
Y = AX  + BX  + CX  + D

FOR EXAMPLE, THE GRAPH OF THE FUNCTION Y = X -1 WOULD LOOK LIKE :

GRAPH OF A FUNCTION

X     Y
-4.00  -5.00        X                       .
-3.80  -4.80         X                      .
-3.60  -4.60          X                     .
-3.40  -4.40           X                    .
-3.20  -4.20            X                   .
-3.00  -4.00             X                  .
-2.80  -3.80              X                 .
-2.60  -3.60               X                .
-2.40  -3.40                X               .
-2.20  -3.20                 X              .
-2.00  -3.00                  X             .
-1.80  -2.80                   X            .
-1.60  -2.60                    X           .
-1.40  -2.40                     X          .
-1.20  -2.20                      X         .
-1.00  -2.00                       X        .
- .80  -1.80                        X       .
- .60  -1.60                         X      .
- .40  -1.40                          X     .
- .20  -1.20                           X    .
0.00  -1.00        ....................X..............................
0.20  -0.80                             X  .
0.40  -0.60                              X .
0.60  -0.40                               X.
0.80  -0.20                                X
1.00   0.00                                . X
1.20   0.20                                .  X
1.40   0.40                                .   X
1.60   0.60                                .    X
1.80   0.80                                .     X
2.00   1.00                                .      X
2.20   1.20                                .       X
2.40   1.40                                .        X
2.60   1.60                                .         X
2.80   1.80                                .          X
3.00   2.00                                .           X
3.20   2.20                                .            X
3.40   2.40                                .             X
3.60   2.60                                .              X
3.80   2.80                                .               X
4.00   3.00                                .                X

( NOTE THAT YOUR GRAPHS WILL BE TWICE AS BIG )

TEST YOUR PROGRAM WITH THE FOLLOWING 2 FUNCTIONS:

3     2
Y = 2X  - 1X  - 22X + 21

2
Y = 8X  - 32
```