CS 150 - Intro to Programming - Fall 2001
Programming Project 4 - 15 points
Due: Thursday, November1 by 2:30pm
Write a C++ program that reads loan data from a file and prints a report that compares the cost of a 30 year
loan to the cost of a 15 year loan. See sample dialog / output below.(note output sent to screen and file). User
input in bold.
Enter input file name: loan.dat
Enter output file name: output.txt
idNum amount rate 15 years 30 years
----------------------------------------------------------------------
123456 100000.00 6.50 871.11 156799.33 632.07 227544.49
123456 100000.00 7.00 898.83 161789.09 665.30 239508.90
123456 100000.00 7.50 927.01 166862.22 699.21 251717.22
654566 670000.00 6.00 5653.84 1017691.33 4016.99 1446115.87
654566 670000.00 7.00 6022.15 1083986.89 4457.53 1604709.62
987345 309666.00 7.50 2870.64 516715.58 2165.23 779482.66
123987 132000.00 8.00 1261.46 227062.94 968.57 348684.93
256389 555332.00 6.50 4837.54 870756.83 3510.08 1263627.36
//*********************** Sample loan.dat file ***********************
123456 100000 6.50
123456 100000 7.00
123456 100000 7.50
654566 670000 6.0
654566 670000 7.0
987345 309666 7.50
123987 132000 8.00
256389 555332 6.5
//output file should look like screen output
NOTES
- Input must come from a file. Output to file and screen.
- Your program must define at least one function that is called with a file stream as an argument. Recall that
streams must be passed by reference.
- Output decimal values to 2 decimal points
- Format output to line up in columns
- Be sure to allow the user to enter the file names - get the program to work by "hard coding" the
file name to start.
- Create your own test files to verify that your program works as required. You can do this in CodeWarrior by
selecting New from the file menu and saving the file in your project folder. Your instructor will have test files
of his own, but you will not know what they contain (except for the above example).
- Add only a few lines to your source code at a time. Then compile and run it to make sure that new errors have
not been introduced.
- make sure to include pre and post conditions, comments, and a comment header for each function.
What to turn in:
Paper copies to be turned in:
yourLastNameP4.cpp
Files to be Turned In to the drop box by the due date shown above:
yourLastNameP4.cpp