CIS 067 Section 1
Assignment Number 05A-F2000

Basic File Input and Output: Mortgage Interest Rate Problem
PRELIMINARY ASSIGNMENT FOR LAB

The work to be done for this assignment relates to the solution of Programming Projects 4 and 5 at the very end of Chapter 8 in the Friedman/Koffman text.

Write a program that uses a function get_data_record . This function is to have full responsibility for reading a single line (record) of input for the Mortgage Interest Rate Problem and return the 5 values read. You will need to create a small 5 to 10 line input file to test this program.

Data Requirements Table for get_data_record (Mortgage Interest Rate Problem):
Name: get_data_record
Purpose: To read a single line of data from an input file and return the five values read.
Return Value: A boolean value set to true if the input of the line worked ok. Set to false otherwise.
Argument List: (all output arguments)

  1. ins (ifstream) - IN: input stream containing data to be read
  2. bank_name (string) - OUT: name of the bank lender
  3. customer (string) - OUT: name of the recipient
  4. mortage_amount (money) - OUT: amount of the mortgage
  5. loan_period (int) - OUT: period of loan in months
  6. loan_rate (float) - OUT: interest rate of loan (in form x.xx)

Hints:

  1. Use a single string such as FCF, Mellon, PSFS, PFCU, Sovereign, and PNC for your bank name. Use only the last name of the loan recipient for now.
  2. In your main program, you should 1) open your input file (see Section 8.2); 2) verify that the open worked, and then 3) enter an eof-controlled while loop (see Section 8.3) which reads your data one record at a time (using get_data_record), displays the record read (using a new function called display_data_record) and computes and prints

    value_a = mortgage_amount * loan_rate
    value_b = mortgage_amount * money(loan_rate)

    If any of your calculations cause syntax errors let us all know via blackboard.

Turn this program in to the grader on MONDAY before noon. Also answer the following questions and turn your answers in to me in class on Monday.

Questions:

  1. If the reading is done in a separate function, how is it that the Main program eof test can work?
  2. How would you alter your program if full bank names and full customer names were used?
  3. The main program is being written mostly just for the purpose of testing your get_data_record function. What do we call such a main program and why are such programs important to the process of writing programs?
  4. What is the C++ construct ifstream as used in your program?