0
我無法弄清楚如何計算一個人有資格獲得貸款的數額以及需要多少年的邏輯公式/數學。下面粗體的文字就是我卡住的地方。任何想法將不勝感激,包括公式建議。C++貸款合格金額
完整的程序規範:
輸入客戶的年收入,年貸款(貸款期)的數量,貸款(貸款額)的量,和客戶的狀態(P爲首選或R定期)。如果客戶符合以下任一條件,請批准貸款。對於普通客戶 - 貸款金額除以貸款期間的月數< =客戶月收入的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;
}