CSCE 2004 - Homework 3
Due Date - Oct 3, 2014 at 11:59 PM

1. Problem Statement:

The goal of this programming assignment is to create an interactive program that uses iteration to demonstrate how compound interest works. In particular, your task is to write a program that will enable a user to plan how to save a million dollars during their working career.

Everyone wants to be a millionaire, but unless you have very good luck with lottery tickets, the only sure way to become a millionaire is to save a portion of your paycheck and let the power of compound interest grow your savings. For example, if someone saves $500 per month and earns 10% interest annually, then they will have over a million dollars in 347 months (29 years). If someone saves $1000/month at 12% interest annually they will be a millionaire in 241 months (20 years).

Your task is to write a program that asks the user:

  • how much money they will save per month
  • what annual interest rate they hope to earn
  • how many months to calculate compound interest
  • what the savings target is (e.g. a million dollars)

    Your program will then output a month-by-month summary that shows:

  • how many months the user has been saving money
  • how much money the user deposited this month (principal)
  • the total amount of money deposited (principal)
  • the total amount of money saved (principal and interest)

    Sample program output:

    Enter monthly savings amount (> 0): 1000
    Enter annual interest rate [0..100]: 12
    Enter duration in months (> 0): 360
    month	deposit		total_deposit	total_saved
    1	$1000.00	$1000.00	$1000.00
    2	$1000.00	$2000.00	$2010.00
    3	$1000.00	$3000.00	$3030.10
    4	$1000.00	$4000.00	$4060.40
    5	$1000.00	$5000.00	$5101.00
    100	$1000.00	$100000.00	$170481.23
    101	$1000.00	$101000.00	$173186.05
    102	$1000.00	$102000.00	$175917.91
    103	$1000.00	$103000.00	$178677.08
    104	$1000.00	$104000.00	$181463.84
    105	$1000.00	$105000.00	$184278.48
    200	$1000.00	$200000.00	$631601.06
    201	$1000.00	$201000.00	$638917.06
    202	$1000.00	$202000.00	$646306.25
    203	$1000.00	$203000.00	$653769.31
    204	$1000.00	$204000.00	$661307.00
    205	$1000.00	$205000.00	$668920.06
    300	$1000.00	$300000.00	$1878843.75
    301	$1000.00	$301000.00	$1898632.12
    302	$1000.00	$302000.00	$1918618.38
    303	$1000.00	$303000.00	$1938804.50
    304	$1000.00	$304000.00	$1959192.50
    305	$1000.00	$305000.00	$1979784.38

    Once this table of information is printed, your program should print out how many months it took to reach the savings target. If the target is not reached, your program should print out a message like "Sorry, savings target not reached".

    NOTE: Most investments (and loans) quote annual interest rates but they apply 1/12th of this rate on a monthly basis. Hence, if you invest $1000 at 12% interest, then after one month you would have earned 1% interest ($1000 * 0.01 = $10).

    BONUS (5 points): To make things more realistic, you can ask the user how much they expect their salary to increase annually. Based on this, you should increase the monthly savings amount every year by a proportional amount. For example, with a 2% raise, the user would save $1000 in each month the first year, $1020 per month the second year, $1040.40 the third year, $1061.21 the next year, etc. This will obviously get them to their savings goal earlier.

    2. Design:

    For this assignment, the first task is reading user input. You must design the prompts to ask the user for input. Then, you must design user input loops with error checking to make sure the user enters valid values.

    Your next task is to design the loop that calculates and prints the compound interest amounts described above. It would be nice to have the results in four columns with appropriate titles at the top of each column.

    Finally, you need to figure out if/when the user has reached their savings target and print out the appropriate message to the user. You will clearly need to calculate this information inside the printing loop, but you should not print this message to the user until after the full table is printed.

    3. Implementation:

    Since you are starting with a "blank piece of paper" to implement this project, it is very important to develop your code incrementally writing comments, adding code, compiling, debugging, a little bit at a time. This way, you always have a program that "does something" even if it is not complete.

    Remember to use good programming style when creating your program -- good names for variables and constants, proper indenting for loops and conditionals, clear comments, etc. Also, be sure to save backup copies of your program somewhere safe. Otherwise, you may end up retyping your whole program if something goes wrong.

    4. Testing:

    Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program with several input values, and save your testing output in text files for inclusion in your project report.

    5. Documentation:

    When you have completed your C++ program, write a short report using the project report template describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report to be submitted electronically.

    6. Project Submission:

    In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted.

    Rename your program and documentation files 123456789.hw3.cpp and 123456789.hw3.docx using your UAID number in place of 123456789, and go the Blackboard site for this class and submit these two files.

    The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

    You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.

    7. Academic Honesty Statement:

  • Students are expected to submit their own work on all programming projects, unless group projects have been explicitly assigned.
  • Students are NOT allowed to distribute code to each other, or copy code from another individual or website.
  • Students ARE allowed to use any materials on the class website, or in the textbook, or ask the instructor and/or GTAs for assistance.
  • This course will be using highly effective program comparison software to calculate the similarity of all programs to each other, and to homework assignments from previous semesters. Please do not be tempted to plagiarize from another student.

    Violations of the policies above will be reported to the Provost's office and may result in a ZERO on the programming project, an F in the class, or suspension from the university, depending on the severity of the violation and any history of prior violations.