CIS200 Spring 2008: Assignment 1
6 points; due Saturday, 2 February, at 10:00pm

Most people don't realize how much money they lose on bank-loan repayments. To protect you against foolish commitments, you will build a repayment calculator that tells you how much money you repay over the life of a loan.

Here is the algebraic equation that defines an annual repayment on a loan:

                    (1 + rate)years * principal * rate
annual_payment =  ---------------------------------------
                    (1 + rate)years - 1
where The answer, annual_payment, is the amount of money the borrower must repay each year to pay back the loan on time. (Since most borrowers repay a loan in monthly payments, calculate the monthly payment as annual_payment / 12.)

Assignment

You must write a Python program, Loan.py, that asks for the principal, years, and interest rate; the program computes and prints Here is a use-case that shows how the program behaves, where the user wishes to learn the cost of a $50,000 loan repaid over 20 years at 7% interest:

$ python Load.py
Welcome to the loan-payment calculator.

Please type the amount of money borrowed, a positive int (no commas): $ 50000
Please type the number of years used to repay the loan, a positive int: 20
Please type the annual interest rate charged on the principal, a fraction.
(e.g., 8.5% is typed as 0.085): 0.07

The annual payment is  $ 4719.64628716
The monthly payment is  $ 393.303857264
The total paid over the life of the loan is  $ 94392.9257433

Please press Enter to finish.
The program computes with fractional numbers (floats), so the answers print in precise fractions of cents --- for now, this is fine.

How to solve the assignment

The assignment uses ideas presented in the Lecture Notes, Chapters 1 and 2. If you are completely new to computer programming, then you should start by reading Dawson's text, Chapters 1 and 2.

When you do this assignment, follow the four stages of program design presented in the lecture notes, Chapter 2:

  1. describe the program's intended behavior (this is already done for you --- see above)
  2. design the program's algorithm (write the algebraic equations that compute the answers)
  3. write the program based on the algorithm and test it
  4. document your work
Here are two hints for writing the Python program:
  1. To compute xy, use pow(x,y), e.g., a = pow(2,3) computes 8 and assigns it to a.
  2. To print a blank line, use just print by itself.
  3. To print multiple items on the same line, insert commas, e.g.,
    year = 2008
    print "This year is", year
    
    displays This year is 2008 on one line in the command window.

Documentation

After you have successfully completed your program, remember to type its commentary at the beginning of the program. Use this format:
# Loan.py
#   ...EXPLAIN HERE what the program does, in one or two sentences.
#  Inputs:
#   ...EXPLAIN the format of the inputs the program needs to do its work
#  Outputs:
#   ...EXPLAIN what the program prints...
#
#  YOUR NAME AND THE DATE OF COMPLETION GO HERE

What to submit and when to submit it

Once you have completed your program and are ready to submit it for grading, please go to the webpage at http://www.cis.ksu.edu/~schmidt/200s08/Assign and follow the link to a web form that lets you submit the assignment. If you are uncertain about what to do, please ask your lab instructor at next week's lab meeting.

Reminder

This is a single-person assignment. You are welcome to discuss the assignment with your instructors, tutors, and other students, but the Python program that you write and submit must be your own work, just as if you are submitting an essay for an English Composition course.