C++ Program : Loan

Interest on a loan is paid on a declining balance, and hence a loan with an interest rate of, say, 14% can cost significantly less than 14% of the balance. Write a program that takes a loan amount and interest rate as input and then off.


#include <iostream>


int main()

{

                char repeat;

   do

   {

                int m = 1;

                                double mp;

                                double b;

                                double ir;

                                double ip;

                                double ib;

                                double tl;


                                cout.setf(ios::fixed);

                                cout.setf(ios::showpoint);

                                cout.precision(2);


                cout<<"This Program is intended for Loan Calculation.\n";

                   cout<<"Please provide the necessary details.\n";

                                cout<<"   Enter the Amount of your Loan: $";

                                cin>>b;

                                cout<<"   Enter the interest rate (compounded) : ";

                                cin>>ir;

                                cout<<"   Enter the desired monthly payment : $";

                                cin>>mp;

                cout<<".................................... Calculating\n";

             

                                ib = b;

                                while (ir >= 1)

                                {

                                                ir = ir / 100;

      }

                                                b = b * (1 + ir / 12) - mp;

                                                cout<<"After month 1 your balance is $"<<b<< endl;


                                                while (b > 0)

                                {

                                                if(b < mp)

                                                                b = b - b;

                                                else

                                                b = b * (1 + ir / 12) - mp;


                                                m = m++;

                                                cout<<"After month " <<m<< ", your outstanding balance is : $" << b <<" \n";

                                }

                cout<<".................................... Calculating Successful!\n";

                cout<<"Congratulation!\n";

                                                cout<<"You have totally paid your loan.\n";


                                                tl = m;

                                                ip = (mp * tl) - ib;


                cout<<"It took you "<<m<<" months to pay the loan.\n";

                cout<<"You paid a total ammount of $" <<ip<< " in intrest.\n";

         cout<<"Do you want another Calculation? [Y/N]\n";

         cin>>repeat;

      } while ((repeat == 'y' || repeat == 'Y'));

         cout<<"Thank You for using this Program!\n";


   cin.get ();

   cin.get ();

                return 0;

}



Share:

No comments:

Post a Comment

Thanks for Suggestion / Comment!

God Bless!

Our Sponsor

Popular Post

Blog Archive