Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(2); //Set to control the number of extra characters in double variables.
- int month;
- int payment;
- double principal; //upphæð láns
- double monthy_intrests = 0.015; //afborganir á mánuði
- double remaning_intrests; //vestir alls
- double intrests_paid; //lokaupphæð láns
- double remaning_dept;//samtals vextir borgaðir
- //Principal : 1000$
- //Intrests : 18% per year (1.5% per month)
- //Monthly payments : 50$
- cout <<"Insert the cost of the item in $ (no more then 2500$) : ";
- cin >> principal;
- cout <<"-------------------------------------------" << endl;
- month = 0;
- payment = 50;
- remaning_dept = principal;
- remaning_intrests = principal - payment;
- do
- {
- intrests_paid = remaning_intrests * monthy_intrests; //Intrest paid = 15$
- remaning_intrests = payment - intrests_paid; //remaning after intrest payment = 50 - 15 = 35$
- remaning_dept = remaning_dept - remaning_intrests; //1000 - 35
- cout << "Month: " << month << ", Interest paid: " << intrests_paid << ", Remaining debt: " << remaning_dept << endl;
- month++;
- }while(remaning_dept >=50);
- do
- {
- }while(remaning_dept =<50);
- cout << "-------------------------------------------" << endl;
- cout << "Number of months: " << month << endl;
- cout << "Total intrest paid: " << intrests_paid << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment