毎月の支払いが *monthly_payment* 関数で見つかった 30% の金額を超えた/等しい場合、変数 *loan_Amt* を出力しようとしています。これは、関数を使用して C++ プログラムを作成する最初の試みです!
#include<iostream>
#include<conio.h>
#include<string>
#include<iomanip>
#include<math.h>
using namespace std;
double monthly_Payment (double amt_Amt)
{
double r;
r = ( amt_Amt/ 12) * 30/100;
return (r);
}
double interest_Calculate(double interest_Amt)
{
double r;
r = (interest_Amt * .010);
return (r);
}
//double loan_Calculate()
//{
//int x = interest_Calculate(interest_Rate);
//double monthly = (loan_Amt * x) / (1 - pow(1.0 + i,-(12*30)));
//for (((int loan_Amt = 20000) * (x/12)) / pow(1.0 + i,-(12*30)); loan_Amt>0; loan_Amt++);
//}
int main()
{
double gross_Salary;
double interest_Rate;
int x;
int i;
double monthly;
std::cout << "Please enter your yearly gross salary:";
std::cin >> gross_Salary;
std::cout << "Please enter an interest rate:";
std::cin >> interest_Rate;
int z;
z = monthly_Payment (gross_Salary);
std::cout << "The target (30 percent of monthly salary) monthly payment range is:" << z;
for ( int loan_Amt = 0; loan_Amt <= 5000000; x++ ) {
do {
x = interest_Calculate(interest_Rate);
monthly = (loan_Amt * x) / (1 - pow(1.0 + x,-(12*30)));
std::cout << loan_Amt;
} while (monthly >= z );
}
getch();
return 0;
}