//Решение для годовой процентной ставки
#include <iostream>
#include <math.h>
#include <iomanip>
#define MONT 12
#define PER 100
using namespace std;
int main()
{
unsigned int credit, period;
double montpay;
cout << "Input loan amount: ";
cin >> credit;
cout << "Input crediting period (years): ";
cin >> period;
cout << setw(15) << "INTEREST RATE | " << setw(15) << "MONTHLY WAGE | " << setw(13) << "TOTAL PAYMENT" << endl;
for(double p = 5.; p <= 8.; p += 1./8) {
montpay = credit * p / MONT / PER * pow(1 + p / MONT / PER, period * MONT) / (pow(1 + p / MONT / PER, period * MONT) - 1);
cout << setw(9) << fixed << setprecision(3) << p << "%" << setw(15) << fixed << setprecision(2) << montpay << setw(16) << fixed << setprecision(2) << montpay * period * MONT << endl;
}
return 0;
//Редактор не сохраняет форматирование => прикрепил .cpp файл
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
//Решение для годовой процентной ставки
#include <iostream>
#include <math.h>
#include <iomanip>
#define MONT 12
#define PER 100
using namespace std;
int main()
{
unsigned int credit, period;
double montpay;
cout << "Input loan amount: ";
cin >> credit;
cout << "Input crediting period (years): ";
cin >> period;
cout << setw(15) << "INTEREST RATE | " << setw(15) << "MONTHLY WAGE | " << setw(13) << "TOTAL PAYMENT" << endl;
for(double p = 5.; p <= 8.; p += 1./8) {
montpay = credit * p / MONT / PER * pow(1 + p / MONT / PER, period * MONT) / (pow(1 + p / MONT / PER, period * MONT) - 1);
cout << setw(9) << fixed << setprecision(3) << p << "%" << setw(15) << fixed << setprecision(2) << montpay << setw(16) << fixed << setprecision(2) << montpay * period * MONT << endl;
}
return 0;
}
//Редактор не сохраняет форматирование => прикрепил .cpp файл