#include <iostream>
using namespace std;
class Mortgage
{
protected:
    double  Payment;        // the monthly payment
    double  Loan;           // the dollar amount of the loan
    double  Rate;           // the annual interest rate
    double  Years;          // the number of years of the loan

public:
    Mortgage()
    {
        Loan = 0;
        Rate = 0;
        Years = 0;
    }
    void setLoan(double n) { if (Loan >= 0) Loan = n; };
    void setRate(double n) { if (Loan >= 0) Rate = n; };
    void setYears(double n){ if(Loan >= 0) Years = n; };

    double getPayment();
    double getAmount() { return Payment * Years *12; }
};

double Mortgage::getPayment()
{
    double Term = pow(1 + Rate / 12, 2 * Years);
    Payment = (Loan * Rate / 12 * Term) / (Term - 1);
    return Payment;
}

int main()
{
    Mortgage mor;
    double d;
    cout << "load = ";
    cin >> d;
    mor.setLoan(d);

    cout << "Rate = ";
    cin >> d;
    mor.setRate(d);

    cout << "years = ";
    cin >> d;
    mor.setYears(d);


    cout << "monthly payment = " << mor.getPayment() << endl;
    cout << "total amount = " << mor.getAmount() << endl;
    return 0;
}