Example input data (read from a file) would be: "2000 4000 5000 3000 7000 8000 12000 10000". The starting point is 1900 with 20 year intervals. Ideally the program should be able to handle more or less input data samples.
I'm not sure how to do this. My first thought was to overlay quadrant 1 of the cartesian coordinate system on the characters to get a matrix. Then I realized I might be able to do a simple vector with a count of the number of asterisks of each character column. I found the formula floor(((n+3) mod 6)/4) will return true for the correct character columns so in theory I can do a loop and do an if true statement to assign an integer value to each element in the vector of how many asterisks are in that character column. If it was false I would assign 0 to that element in the vector.
Then once everything is in the vector I imagined doing a ranged based for loop with an if statement that would check if the value in the vector element was greater then 0. If it was greater then 0 it would write an asterisks to the screen and then de-increment the value of the element by 1. If the element was equal to 0 it would write a space to the screen.
For the legend on the y axis it can simply be right justified with a width of like 10 characters so everything lines up correctly.
I'm not sure how to pieces all of these steps into a cohisive procedural program.
1. Read input data from file. Number of data samples is unknown, but it always starts at 1900 and has a 20 year interval and is an integer divisible by 1000.
2. Divide all of the data samples by 1000.
3. Put transformed data into a vector.
3.5 Put the data sample into the vector twice (two elements) so the two elements align with the triggering provided by the floor(((n+3) mod 6/4) formula.
4. ????
5. Loop through another vector that has an element for each character column of a 80 column by 30 row console window using the formula floor(((n+3) mod 6)/4) to trigger on.
6. In the loop when y of f(x) = 1 read the value from the nth element in the first vector and assign it to the nth element in the second vector. If y of f(x) = 0 then assign 0 to that element in the second vector.
7. Once all the values are in the second vector then iterate through the vector and when the value of the element is greater then 0 write an asterisk to the screen and de-incrament the value in the element by 1. If the value in the element is equal to 0 then write a space to the screen.
7.5. Repeat step 7 to fill the display up line by line until all values in the vector equal 0.
8. Also, I forgot, the first column needs to be a legend, so loop through those numbers too and set to right justification with a column width of like 10, then write that number to the screen, then set the display back to left justification and write the rest of the character column lines.
9. Then the last step is to write the bottom legend for the year values.
Thinking about it more I think it would be better to do a single loop that is triggered by the floor(((x+3) mod 6)/4) function. When f(x) is true it reads the value in the file, divides it by 1000, and then stores that value directly in the nth element of the character column vector. When f(x) is false it assigns a 0 to the nth element of the character column vector.
Alternatively, is it possible to input the value in the vector and then duplicate the value of each element in said vector and then add pad it with two 0 on each side? i.g. { a, b, c, d } ---> { a, a, b, b, c, c, d, d } ---> { 0, 0, a, a, 0, 0, 0, 0, b, b, 0, 0, 0, 0, c, c, 0, 0, 0, 0, d, d }
Or how about this?: { a, b, c, d } ---> { a, 0, 0, 0, 0, b, 0, 0, 0, 0, c, 0, 0, 0, 0, d } ---> { 0, 0, a, a, 0, 0, 0, 0, b, b, 0, 0, 0, 0, c, c, 0, 0, 0, 0, d, d }
Or how about this?: { a, b, c, d ) ---> { a, 0, b, 0, c, 0, d } ---> { a, a, 0, 0, b, b, 0, 0, c, c, 0, 0, d, d } ---> { 0, 0, a, a, 0, 0, 0, 0, b, b, 0, 0, 0, 0, c, c, 0, 0, 0, 0, d, d }