COB logoCOB honor code logo

BA371 VC#.NET Assignment 1: Compound Interest Graph

This assignment assumes that you more or less master the various topics demonstrated and practiced in BA272 and the following BA371 labs:

Before you start this assignment, first follow these instructions for setting up the proper file structure on your ONID system (so that your instructor can harvest your work).

In this assignment, we write a (Console) program which computes the growth of a capital asset (or debt?) under compound interest under a variety of interest rates. The program writes the results to an HTML file which, when displayed in a Web browser, shows the results as a line chart (see images below).

Inputs to the program, given by the user on the console when prompted, are the following:

Here's the gist of things:

Notice how in the top image the program prompts the user for the input data. In this case the user specifies a starting capital of 1000, a low interest rate of 1%, a high interest rate of 5% and 10 interest intervals, which means that we compute profiles for 11 interest rates: 1.0, 1.4, 1.8, ..., 5.0. The user also specifies a time horizon of 25 periods, meaning that we compound 25 times (for each of the interest rates). We assume a compounding frequency of once per period; i.e., interest is added only at the end of each period.

The bottom image shows the results: 11 compound profiles (10 intervals yieilds 11 profiles), each covering 25 periods.

There are two important issues to consider here:

  1. How to compute the numbers.
  2. How to make a graph out of these numbers.
Starting with the second issue; the graph is a so-called (standard, non-zoomable) Google Line Chart. The following is the HTML/JavaScript code for a simple random Google line chart:

 1 <html>
 2  <head>
 3    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
 4    <script type="text/javascript">
 5      google.load("visualization", "1", {packages:["linechart"]});
 6      google.setOnLoadCallback(drawChart);
 7      function drawChart() {
 8        var data = google.visualization.arrayToDataTable([
 9          ['Year', 'Sales', 'Expenses'],
10          ['1',  1000,      400],
11          ['2',  1170,      460],
12          ['3',  660,       1120],
13          ['4',  1030,      540]
14        ]);
15
16        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
17        chart.draw(data, {width: 1000, height: 500, legend: 'bottom', title: 'Company Performance'});
18      }
19    </script>
20  </head>
21
22  <body>
23    <div id="chart_div"></div>
24  </body>
25 </html>
If you store this code (!!!minus the line numbers!!!) in a file; e.g., foo.html and load that file into your browser (use cntrl-o in your Web browser to pop up a file browser), it will display the chart. !!!TRY THIS!!!

Now take a good look at the chart code:

Comparing this with the compound interest example, we can infer that what our program has to do is to write a file with content in the exact same format as the example, use the same content as in lines 1-8, 14-16 and 18-25, yet replace lines 9-13 and line 17 with the data for the compound interest problem. Lines 10-13 will be replaced with as many lines as your user specifies periods and instead of the columns Sales and Expenses you will have as many columns as your user specifies the number of interest intervals + 1).

Please study this a little, so that you develop a good sense of how the Compound Interest program resembles the example chart and how it is different.

There are, as always, several ways to program this, but the following approach works well:

 

Requirements

The program should exhibit the following behavior and structure:

Please Note!!

  • Some Hints
  • Please review the grading criteria