Plotting graphs on a dumb (vt100) terminal |
You have a client who is a mathematician and wants you to write a program to plot graphs. Unfortunately, all he has is a vt100 (i.e. ASCII, non-graphic) terminal that connects to the department server. This terminal can display 41 lines of text at a time, and each line has 61 characters. Your graph plotting program must work on this setup.
Your current task is to write a program that plots only linear functions -- you need to see how graphs look on such a terminal, before proceeding further, Remembering that the equation for a linear function is y=ax + b, you see that you need two inputs a,b. You can assume that the range of x and y for which the function needs to be plotted are 0 <= x <= 6.0, and 0 <= y <= 40. Each point on the graph is marked with a "*" and the axes are marked with the characters "|" and "-" (see the sample output). The graph has 60 points, one for each non-zero value of x. Each point is rounded to the nearest character; e.g. y=4.51 for some x implies that a star be drawn corresponding to y=5. If a point is out of range (i.e. if y>40), the point can be ignored. For simplicity, all non-graph points are blanks (" ") in the output file. Any point that lies on an axis is not plotted.
10.0 1.0
| * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * | * |* | -------------------------------------------------------------