C++ 贷款合格金额

标签 c++ finance

我想不出逻辑方程/数学来计算一个人有资格获得多少贷款以及需要多少年。下面的粗体文字是我卡住的地方。任何想法,包括公式建议,我们将不胜感激。

完整的程序规范:

输入客户的年收入、贷款年数(贷款期限)、贷款金额(贷款金额)和客户的身份(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;

最佳答案

if(status != 'P' || 'R')

应该是:

if(status != 'P' && status != 'R')

很明显你在preferred_validation <=时拒绝了贷款annualIncomeTest`,那么 max_amount 应该是 annualIncomeTest?

max_amount= annualIncomeTest;

关于C++ 贷款合格金额,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14668996/

相关文章:

c++ - WinApi中的GetClientRect和GetWindowRect有什么区别?

c++ - 从输入流中读取

c++ - 通过指针问题

r - 在没有 xts 对象的情况下在 PortfolioAnalytics 中创建有效边界

R:向图中添加文本不起作用

python - 在 Python 中使用 GARCH 预测波动性 - Arch Package

c++ - gcc 4.8 的任何正则表达式库

c++ - 从 std::find_if 等方法返回的迭代器与常规迭代器不匹配

hadoop - 如何在 Hadoop 上实现数据沿袭?

cassandra - 在 Bigtable 衍生品中存储大量有序时间序列数据