now we just need to figure out where the opposite (upper rightcorner of the bar should be so that we can draw an appropriate rectangle in the vertical directionthe height of the bar is determined by the value of principal in drawing the scalewe determined that pixels is equal to $ , this means that we have / pixels to the dollar this tells usfor examplethat principal of $ , should produce bar of height pixels in generalthe position of the upper-right corner will be given by -(principal)( (remember that is the pointand the coordinates decrease going uphow wide should the bar bethe window is pixels widebut pixels are eaten up by the labels on the left that leaves us with pixels for bars / let' just make each bar pixelsthat will give us bit of margin on the right side sothe right edge of our first bar will be at position we can now fill in the details for drawing the first bar into our algorithm draw rectangle from ( to ( principal at this pointwe have made all the major decisions and calculations required to finish out the problem all that remains is to percolate these details into the rest of the algorithm figure shows the general layout of the window with some of the dimensions we have chosen ( , ( , ( , ( , figure position of elements in future value bar graph let' figure out where the lower-left corner of each bar is going to be located we chose bar width of so the bar for each successive year will start pixels farther right than the previous year we can use variable year to represent the year number and calculate the coordinate of the lower left corner as (year)( (the + leaves space on the left edge for the labels of coursethe coordinate of this point is still (the bottom of the graphto find the upper-right corner of barwe add (the width of the barto the value of the lower-left corner the value of the upper right corner is determined from the (updatedvalue of principal exactly as we determined it for the first bar here is the refined algorithm