I cannot figure out the logical equation/math on how to figure out what amount a person would qualify at for a loan and the number of years it would take. The text in bold below is where I'm stuck. Any ideas would be appreciated, including formula suggestions.
Complete program specification:
Inputting the customer’s annual income, number of years of the loan (loan period), the amount of the loan (the loan amount), and the customer’s status (P for Preferred or R for Regular). Approve the loan if the customer meets either of the following conditions. For a Regular customer - the loan amount divided by the number of months in the loan period <= to10% of the customer’s monthly income. Or, if the customer is a preferred customer, the loan amount divided by the number of months in the loan period <= 1% of the customer’s annual income. Output approval or disapproval.
What I can't figure out:
If the loan is disapproved (2) tell the customer the maximum amount the loan could be based on current income (3) how long the period (round up to the nearest whole year) would have to be to approve the loan at the current income.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double income, preferred_validation, regular_validation, years, loan_amount, monthlyIncome, annualIncomeTest, max_amount, request_amount;
char status;
cout<<"Please enter the annual income of the customer: ";
cin>>income;
cout<<"\nPlease enter the number of years of the loan: ";
cin>>years;
cout<<"\nPlease enter the amount of the loan: ";
cin>>loan_amount;
cout<<"\nCustomer status: P - Preferred R - Regular."<<endl;
cout<<"Please enter the customer's status: ";
cin>>status;
if(status != 'P' || 'R')
{
status='R';
cout<<"\n\nThe customer status code you input does not match one of the choices.\nThe calculations that follow are based on the applicant being a Regular customer."<<endl;
}
if(status=='R')
{
regular_validation=loan_amount/(years*12);
monthlyIncome=((income/12)*.10);
if(regular_validation<=monthlyIncome)
{
cout<<"\nThis loan is approved.";
}
else
{
cout<<"\nThis loan is disapproved.";
}
}
else if(status=='P')
{
preferred_validation=loan_amount/(years*12);
annualIncomeTest=income*.01;
if(preferred_validation<=annualIncomeTest)
{
cout<<"\nThis loan is approved.";
}
else
{
cout<<"\nThis loan is disapproved."<<endl;
max_amount=???;
cout<<"As a preferred customer, the largest loan you qualify for is "<<max_amount<<" or you can get the requested amount of "<<loan_amount<<" by increasing the loan period to "<<years<<" years.";
}
}
else
{
cout<<"Restart and enter your customer status.";
}
cin.get();
cin.get();
return 0;
}
if(status != 'P' || 'R')
Should be:
if(status != 'P' && status != 'R')
Obviously you reject the loan when preferred_validation <=
annualIncomeTest`, then max_amount should be annualIncomeTest?
max_amount= annualIncomeTest;