Question

THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some...

THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some software that will process their daily loan information. The data will come from a text file that has the following format:

The first line will contain an integer: number of loan applications

There will be two rows for each of the customers

First line will be the customer's (1) first name and (2) last name, separated by a space (assume there is no spaces in the actual names)

Second line will contain: (1) number of years (an integer), (2) amount of the loan (floating-point number), (3) annual interest rate stated as a percent value (floating-point number), (4) the amount per month that the customer is qualified (floating-point number)

A sample data file looks like this:

3

Mickey Mouse

20 100000 4.75 1000

Donald Duck

30 200000 5.25 1000

Minnie Mouse

30 245000 4.75 1500

The program should begin by asking the user for the name of the input file. If the file does not exist, a message should be displayed and the program should end.

For each customer, the program should compute the monthly mortgage payment using the following formula:

P = (r(PV)) / (1 - (1 + r)^-n)

P= Payment

PV = Present Value

r = rate per period

n = number of periods

Notes: The Present Value is the loan amount the customer has requested. The rate per period is the annual rate divided by the number of periods per year (which 12 since payments are made monthly). If the rate given was 3.0%, for example, the rate per period would be (3.0/100)/12, or .0025. The number of periods is the total number of payments made over the course of the loan. A 20-year loan would have 20*12, or 240 payments.

The program should display a table with the loan information. For each user, you should display first name, last name, the qualified amount, and the monthly payment. If the monthly payment is not more than the qualified amount, the program should also display the number of payments, the total amount paid, the loan amount, and the total interest paid.

The formatting for the table is important. Column headings should be displayed above each column. Names should align to the left and the numbers aligned to the right. Two decimals should be output for floating-point numbers. The output that would correspond to the input file from the previous page is displayed below.

After the table, your program should output the total number of loan applications, the number of qualified loans, and the average loan payment of the qualified loans.

First     Last      Qualified    Payment Number Total Paid    Loan Amount   Total Interest

Mickey    Mouse      1000.00      646.22   240     155092.80     100000.00      55092.80

Donald    Duck       1000.00     1104.41

Minnie    Mouse      1500.00     1278.04   360     460094.40     245000.00     215094.40

Number of loan applications: 3

Number of qualified loans:   2

Average loan payment: 962.13

0 0
Add a comment Improve this question Transcribed image text
Answer #1

dailyLoanInfo.txt

3
Mickey Mouse
20 100000 4.75 1000
Donald Duck
30 200000 5.25 1000
Minnie Mouse
30 245000 4.75 1500

_________________

#include <fstream>

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

int main() {

string fname,lname;

double qualified,totPaid=0,loanAmt,totInterest=0;

double annualRate,minterest,mpayment,overallTot=0;

int number,years;

//Setting the precision

cout<<setprecision(2)<<fixed<<showpoint;

//defines an input stream for the data file

ifstream dataIn;

int noOfLoanApplications,noOfQualifiedLoans=0;

//Opening the input file

dataIn.open("dailyLoanInfo.txt");

//checking whether the file name is valid or not

if(dataIn.fail())

{

cout<<"** File Not Found **";

return 1;

}

else

{

dataIn>>noOfLoanApplications;

{

cout<<"First Last Qualified Payment Number Total Paid Loan Amount Total Interest"<<endl;

cout<<"----- ---- --------- -------------- ---------- ----------- -------------"<<endl;

for(int i=0;i<noOfLoanApplications;i++)

{

dataIn>>fname>>lname>>years>>loanAmt>>annualRate>>qualified;

minterest=annualRate/1200;

number=years*12;

  

mpayment=(loanAmt*minterest) / (1-pow(1+minterest, -number));

totPaid=number*mpayment;

totInterest=totPaid-loanAmt;

cout<<fname<<" "<<lname<<" "<<qualified<<"\t"<<mpayment<<"\t";

cout<<number<<" "<<totPaid<<"\t"<<loanAmt<<"\t"<<totInterest<<endl;

if(qualified>=mpayment)

{

noOfQualifiedLoans++;

}

overallTot+=mpayment;

}

}

  

cout<<"Number of loan applications: "<<noOfLoanApplications<<endl;

cout<<"Number of qualified loans: "<<noOfQualifiedLoans<<endl;

cout<<"Average loan payment: "<<overallTot/noOfLoanApplications<<endl;

//Closing the intput file

dataIn.close();

}

return 0;

}

______________________

Output:

CAProgram Files (x86) Dev-CpplMinGW641bin ReadFileFindMonthly Payment.exe First Last Qualified Payment Number Total Paid Loan Amount Total Interest Mickey Mouse 1000.00 646.22 240 155093.67 100000.00 DonaldDuck 1000.00 Minnie Mouse 1500.00 1278.04 360 460092.95 245000.00 Number of loan applications 3 Number of qualified loans: 2 Average loan payment: 1009.56 55093.67 197586.6? 215092.95 1104.41 360 397586.67200000.00 Process exited after 0.04913 seconds with return value E Press any key to continue - - -

__________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
THE PROBLEM: The nice folks from the Lion Lending Company have hired you to write some...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi, can you help me with Part E? Please use Java language. So for this Part,...

    Hi, can you help me with Part E? Please use Java language. So for this Part, you will be given 3 files of starter code that is already done for you. All you have to do is to add on to it in order to produce the exact output shown in the pictures below. Please only add on to the code, but not change any of them. Out of the 3 given files, 1 of them is already completed. The...

  • Program Specification: This project involves implementing a Java program that performs a calculation of payments associated...

    Program Specification: This project involves implementing a Java program that performs a calculation of payments associated with loans. The program shall allow a user to enter the following data: annual interest rate the loan (i.e. , number of years), and the loan amount. A GUI like the one below must be used. Loan Calculator Annual Interest Rate: Number of Years Loan Amount: Monthly Payment Total Payment Calculate When the user presses the calculate button, the monthly payment and total amount...

  • 1) You wish to borrow $150,000 from a lending institution for the purchase of a house....

    1) You wish to borrow $150,000 from a lending institution for the purchase of a house. The bank will lend this amount at an Annual Percentage Rate of 4.5% to be paid-off with equal monthly mortgage payments over a 30-year period. This is a 4.5% APR, 30-year fixed-rate mortgage loan. You wish to know how this loan will affect your federal income tax burden, as only the interest paid on a home mortgage, not the principal, is tax deductible. Construct...

  • c++ and please add tables and everything and make sure program is complete. Write a menu...

    c++ and please add tables and everything and make sure program is complete. Write a menu driven program, which would compute compound interest and a monthly payment for a loan. The user will be given a choice to display the info on the screen or to a filo Menu will be the following Enter (1) to calculate your loan monthly payment Enter (2) to calculate your loan monthly payment & write to a file Tips: Compound Interest Formula A =...

  • 19. Monthly Payments The monthly payment on a loan may be calculated by the following formula:...

    19. Monthly Payments The monthly payment on a loan may be calculated by the following formula: Rate (1Rate) ((1 Rate)N - 1) Payment - Rate is the monthly interest rate, which is the annual interest rate divided by 12" (12% annual interest would be 1 percent monthly interest.) N is the number of payments, and L is the amount of the loan. Write a program that asks for these values and displays a report similar to Loan Amount: Monthly Interest...

  • When you borrow money to buy a house, a car, or for some other purpose, you...

    When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that...

  • USE MATLAB TO WRITE A CODE FOR THIS 2. Writ example 4.5% as 4.5) and the...

    USE MATLAB TO WRITE A CODE FOR THIS 2. Writ example 4.5% as 4.5) and the number of monthly payments (use the Calculate the down payment using the percent down payment e e a program that gets a cost, percent down payment, annual interest rate as a percent (for ntered, the loan amount (cost - own payment) and monthly interest rate as a decimal number -not a percent. Call your payment function to calculate the payment on the loan amount....

  • CIS 221 Loan Calculator Enhancement Introduction You are a systems analyst working for a company that...

    CIS 221 Loan Calculator Enhancement Introduction You are a systems analyst working for a company that provides loans to customers. Your manager has asked you to enhance and correct their existing Loan Calculator program, which is designed to calculate monthly and total payments given the loan amount, the annual interest rate, and the duration of the loan. Although the current version of the program (hereby termed the “As Is” version) has some functionality, there are several missing pieces, and the...

  • PYTHON ONLY PLEASE (Financial application: compare loans with various interest rates) Write a program that lets...

    PYTHON ONLY PLEASE (Financial application: compare loans with various interest rates) Write a program that lets the user enter the loan amount and loan period in number of years and displays the monthly and total payments for each interest rate starting from 5% to 8%, with an increment of 1/8. Sample Run Loan Amount: 10000 Number of Years: 5 Interest Rate Monthly Payment Total Payment 5.000% 188.71 11322.74 5.125% 189.29 11357.13 5.250% 189.86 11391.59 ... 7.875% 202.17 12129.97 8.000% 202.76...

  • Number 16. Chapter 3 Problem Comes from "Starting out with >>> C++ From Control Structures through...

    Number 16. Chapter 3 Problem Comes from "Starting out with >>> C++ From Control Structures through Objects" Ninth Edition. Checking work Programming Challenges 147 16. Senior Citizen Property Tax Madison County provides a $5,000 homeowner exemption for its senior citizens. For example, if a senior's house is valued at $158,000, its assessed value would be $94,800, as explained above. However, he would only pay tax on $89,800. At last year's tax rate of $2.64 for cach $100 of assessed value,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT