【问题标题】:C++ Loan Qualifying AmountC++ 贷款合格金额
【发布时间】:2013-02-03 02:48:20
【问题描述】:

我无法弄清楚如何计算一个人有资格获得贷款的金额以及所需年数的逻辑方程式/数学。下面粗体字是我卡住的地方。任何想法都将不胜感激,包括公式建议。

完整的程序说明:

输入客户的年收入、贷款年数(贷款期限)、贷款金额(贷款金额)和客户状态(P 代表 Preferred 或 R 代表 Regular)。如果客户满足以下任一条件,则批准贷款。对于普通客户 - 贷款金额除以贷款期间的月数

我想不通:

如果贷款未获批准 (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;

}

【问题讨论】:

    标签: c++ finance


    【解决方案1】:
    if(status != 'P' || 'R')
    

    应该是:

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

    显然preferred_validation &lt;=annualIncomeTest`时你拒绝贷款,那么max_amount应该是annualIncomeTest?

    max_amount= annualIncomeTest;
    

    【讨论】:

      猜你喜欢
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      • 2018-06-12
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2016-05-24
      • 1970-01-01
      相关资源
      最近更新 更多