CIS 067 Section 1
Assignment Number 05-F2001

Basic File Input and Output: Mortgage Interest Rate Problem

Reading: Complete the reading required for Sections D (I/O, Streams, and Files) and E (Arrays and Structs) of the Syllabus.

Programming: This program needs to be carefully modularized. Your program components should be clearly and completely documented, each component on a separate page:

Þ You are to write a program similar to what is described in Programming Projects 4 and 5 (pages 421 and 422 of the Friedman/Koffman text) but with the following modifications.

  1. Put a switch named test_switch in your program. At the start of the program, ask the user if they wish to run in test mode (T) or production mode (P). Set your test_switch accordingly.
  2. All dollar figures should be handled using the money data type.
  3. (Test mode run) Interactively enter a bank name, a loan recipient, a loan amount (such as $100000) a loan duration (such as 360 months), and a loan rate (such as 5.75%). Print out the following information as a test of your program. Get the date from the computer using a function in the time.h C Standard Library.

    Mortgage Loan Test Run                  DATE _________
    Name of Bank ___________
    Name of Loan Recipient ______________
    Amount of Loan $______ Loan Duration _____ months Loan % ____

    Month     Monthly Payment      Accumulated Total
    1
    2
    ...

  1. (Production mode run) Test your program with eight to ten different meaningful mortgage loan values (say $85,000, $117,000, $150,000, $200,000, $500,000), meaningful periods for the loan [say 180 months (15 years), 360 months (30 years), or 300 months (25 years)], and meaningful percents (5.5%, 6.5%, 7.5%). After all data has been read and results have been displayed, compute the mean and median values of the loan payments for all bank customers. Be sure each test is accompanied by the name of the bank making the loan and the name of the recipient. For example, your input file might contain the following data records:

    Fox Chase Federal Frank Friedman 100000. 360 7.25
    Mellon Bank Catfish Hunter 85000. 360 5.75
    Philadelphia Federal CU Peter Liacouras 250000. 180 5.50
    Sovereign Bank David Adamany 250000. 180 5.50
    PNC Allan Shears 120000. 300 6.00
    Wells Fargo Barry Bonds 2500000. 360 4.75
    First Union Gary Fredericks 75000. 360 5.25

    Your output should include 7 columns with headers and data for

    BANK   LOAN     LOAN PERCENTAGE  LOAN   MONTHLY  TOTAL
    NAME RECIPIENT AMOUNT   RATE   DURATION PAYMENT PAYMENT

    The mean (average) total payment is $ xxxxx.xx
    The median total payment is $ xxxxx.xx

  1. Special Instructions for the Production Mode part of your program:
  1. Because you need to compute a median total payment, you will need to store all input and computed values in a single array of structs named mortgage_records. You will have one struct for each bank customer who has a loan. Each element of your array (a struct or record) will be of type customer_record and will consist of seven fields, one for each of the columns appearing in the table shown above. You should still read and process one record at a time as you did before, but your data and your computed results will have to be saved for all records in your arrays. Test your program on 6 to 10 data records. Use an array of size 15.
  2. Even though you are stroring your input and results in an array of structs, you should not need to modify your original get_data_record function.

Turn In:

By Friday, October 12 (to the lab assistant):

  1. Structure Chart for the Program.
  2. A Behavior Diagram for the process described above.
  3. The Data Requirements Table for the Main program with interfaces for second level functions.
  4. Data Requirements Table for the second level functions illustrating interfaces and local variables and interfaces for any third level functions called.

Save copies of all of this work for your own use.

By Friday, October 19 (to the lab assistant):

  1. The entire program and functions, appropriately commented.