My double keeps getting rounded

One of my assignments is to calculate the interest on a mortgage payment.

Everything is fine except the mortgage principal balance keeps getting rounded. I want the balance to read 145200.87 but it keeps getting rounded for an unknown reason. It gets rounded to 145201. Does any1 know why my double does that?

1
2
3
4
5
6
7
8
9
10
11
12
13
double MortgagePrincipalBalance = (145200.87);
    double MonthlyMortgagePayment (1200.45);
    double MonthlyInterestRate (.0749);


    cout << "Principal Balance: $" << MortgagePrincipalBalance << '\n';
    cout << "Monthly Mortgage: $ " << MonthlyMortgagePayment << '\n';

    double MonthlyInterest = MonthlyMortgagePayment * MonthlyInterestRate / 12;
    double MonthlyPrincipalAmount = MonthlyMortgagePayment - MonthlyInterest;

    cout << MonthlyInterest << '\n';
    cout << MonthlyPrincipalAmount << '\n';
Topic archived. No new replies allowed.