我无法弄清楚如何计算一个人有资格获得贷款的金额以及需要的年数的逻辑方程式/数学。下面粗体字是我卡住的地方。任何想法都将不胜感激,包括公式建议。
完整的程序规范:
输入客户的年收入、贷款年数(贷款期限)、贷款金额(贷款金额)和客户状态(P 代表 Preferred 或 R 代表 Regular)。如果客户满足以下任一条件,则批准贷款。对于普通客户 - 贷款金额除以贷款期间的月数 <= 客户月收入的 10%。或者,如果客户是优先客户,贷款金额除以贷款期间的月数<=客户年收入的1%。输出批准或不批准。
我无法弄清楚:
如果贷款未获批准 (2)告诉客户贷款可以根据当前收入计算的最高金额(3)需要多长时间(四舍五入到最接近的全年)才能在当前收入下批准贷款.
#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;
}