#include <iostream>
int main() {
double loan = 1000.0 , interest_paid = 0.0 , total_interest = 0.0;
const double INTEREST = 0.015;
const int PAYMENT = 50;
int month = 0;
while( loan > 0 )
{
interest_paid = loan * INTEREST;
total_interest += interest_paid;
loan -= PAYMENT + interest_paid;
++month;
}
std::cout << "It took " << month << " months to pay off the loan." << std::endl;
std::cout << "You paid overal $" << total_interest << " in loans." << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKSB7Cglkb3VibGUgbG9hbiA9IDEwMDAuMCAsIGludGVyZXN0X3BhaWQgPSAwLjAgLCB0b3RhbF9pbnRlcmVzdCA9IDAuMDsKCWNvbnN0IGRvdWJsZSBJTlRFUkVTVCA9IDAuMDE1OwoJY29uc3QgaW50IFBBWU1FTlQgPSA1MDsKCWludCBtb250aCA9IDA7CgkKCXdoaWxlKCBsb2FuID4gMCApCgl7CiAgICAgICAgaW50ZXJlc3RfcGFpZCA9IGxvYW4gKiBJTlRFUkVTVDsKICAgICAgICB0b3RhbF9pbnRlcmVzdCArPSBpbnRlcmVzdF9wYWlkOwogICAgICAgIGxvYW4gLT0gUEFZTUVOVCArIGludGVyZXN0X3BhaWQ7CgkJKyttb250aDsKCX0KCXN0ZDo6Y291dCA8PCAiSXQgdG9vayAiIDw8IG1vbnRoIDw8ICIgbW9udGhzIHRvIHBheSBvZmYgdGhlIGxvYW4uIiA8PCBzdGQ6OmVuZGw7CglzdGQ6OmNvdXQgPDwgIllvdSBwYWlkIG92ZXJhbCAkIiA8PCB0b3RhbF9pbnRlcmVzdCA8PCAiIGluIGxvYW5zLiIgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=