Description
Using Visual Studio 2017 create a CLR console application. Create a program plan and then convert it into C++ statements. Practice debugging, declaring variables, type casting, formatting output, if statements and input /output to / from the console window and files.
Always bring to class
1. Class notes, handouts, book if you need to refer to it.
2. USB Flash drive(s) or other storage media.
Mandatory Instructions
When creating your Visual Studio solution to this assignment make sure to name it with your last name, initial and then ‘program 2’ as in this example: Smith John would name his solution – SmithJ Program 2. Give unique name to your source file rather than soruce.cpp which is the default name. Use your own name such as SmithJ source.cpp.
Rate*(1 Rate)N
Payment = ((1 Rate)N 1) *LoanAmt
where Rate is the monthly interest rate, N is the number of payments, and LoanAmt is the amount of the loan. (Notice that the monthly interest rate is the annual interest rate divided by 12. For example, a 12% annual interest rate would be 1% monthly interest rate.)
In this assignment, you will be writing a complete C++ program that calculates the monthly payment and produces a report for a given loan. Suppose that the interest rate is calculated based on the type of loan (auto loan or mortgage), loan amount and the length of the loan as given in the following table:
Loan Type Length Annual Interest Rate
Auto Loan 36 months 2.99 %
48 months 3.02 %
60 months 3.89 %
Mortgage 15 years 3.12 %
20 years 3.625 %
30 years 3.87 %
(Add 1.5% if loan amount >= $200,000)
Your program will ask the user to enter the type of loan, loan amount and the number of payments, and figure out the interest rate according the user input. The program will then calculate the monthly payment, total payment and interest paid, and display the loan report. For example for a $10,000, 36-month auto loan, with annual interest rate of 2.99%, the loan report should look like the following:
— Loan Report —
Loan Type: Auto
Loan Amount: $ 10000.00
Annual Interest Rate: 3.72%
Number of Payments: 36
Monthly Payment: $ 294.00
Total Payment: $ 10583.85
Interest Paid: $ 583.85
Use techniques such as setw, fixed, showpoint, setprecision, left and right to format your output. Pay close attention to spacing and the number of digits after the decimal point.
Output File
Make sure you test your program with various loans and amounts. Once you have verified that the program is working correctly, modify your program so that it ALSO outputs the result to a file named report.txt. That means you will display the results on the screen, and at the same time, save them into the file. In order to do this, you need to have two output statements, one for the screen and one for the file, for each piece of information that you want to display. For example, to print the report title, you will have both of the following two statements assuming outfile is the output file object you have created.
cout << “— Loan Report —” << endl; outfile << “— Loan Report —” << endl;
Sample Program Execution (not same rates as in your assignment)
Program Documentation & Style:
1. Declare all variables and constants that your program uses at the beginning of your program.
2. Your program should include two types of comments:
a. Header Comments at the top including lines with:
– Your name, course name, and class time
– A sentence or two explaining the purpose of the program
– A description of the input data needed by the program when you run it
– A description of the processing (calculations) done by the program
– A description of the results (output) produced by the program
b. In-line comments: There should be an in-line comment for each main step in your program. In general, this means a comment with each group of C++ statements that handle the declarations, input, processing, and the output steps of your program
3. Use meaningful identifier names
4. Include clear prompts for the user about entering the data
5. Include clear descriptions of the results when you display them
What to turn in?
1. Log into Canvas, locate this assignment, and upload the compressed project folders.
2. Upload the grade sheet (Word document) after you have edited it to provide requested information.
3. You’re done.
Reviews
There are no reviews yet.