CSc 233 Assignment 1 | |
CSc 233 Ada Assignments |
70 pts |
Curve Ball |
Due: July 6 |
Write an Ada program to plot a curve of a polynomial. Your program takes one line containing seven integers which describe the curve to generate. They are:
Count | The number of x values to print. This is non-negative. |
Start | The first x value. |
Step | The increment between x values. |
A, B, C | The coefficients of the polynomial, which is Ax2 + Bx + C. |
Divisor | This is a scale factor; the polynomials value is divided by this before being plotted. |
Plot one x value horizontally on each line. Use floating point
arithmetic to compute the y value for each x, then convert it
to integer. On the line, print out y spaces followed by an
asterisk. This will place the asterisk in the yth postition on
the line, numbering from zero. If y is outside the range 0 to
78 (does not fit on line), print a blank line. For instance:
For instance, on the first line x has the start value of -10.
The polynomial is 3x2 + 2x + 5; evaluated at
x = -10, this is 285. We divide by the scale of 20, which gives
14.25. Converting to integer gives 14. If you look on the first line,
you will see fourteen spaces followed by the asterisk. The program
repeats the calculation for x = -9 for the next line, and so forth.
The last line is x = 19, which produces
(3 × 192 + 2 × 19 + 5) / 20 = 56.3.
[tom@laptop asst]$ lpoly
30 -10 1 3 2 5 20
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Submission
When your program works and is nicely formatted and commented, submit it using the form here.