Monday, September 26, 2016

Interest Rate Solver in Text File in C++

A simple program that I wrote a long time ago in C++ that will compute the interest rate of the amount being loaned and then save the results in a text file.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <iomanip>
#include <fstream>


using namespace std;

main() {

    string name;

    int principal=0;
    int number_months=0;
    float rate=0.00,solve_rate=0.00;

    ofstream file("report.txt");

    cout << "\t  Kwarta Agad Lending Investor";
    cout << "\n\n";
    cout << "Enter Customer Name    :=> ";
    getline(cin,name);
    cout << "\nEnter Amount  Loan   :=> ";
    cin >> principal;
    cout << "\nNumber of Months    :=> ";
    cin >> number_months;
    cout << "\nEnter Rate Per Month :=> ";
    cin >> rate;
    solve_rate = (principal * number_months * rate ) ;
    cout << "\n\n";
    cout << fixed << setprecision(2);
    cout << "The Simple Interest Rate is Php "
         << solve_rate << ".";

    file << "\n\t ======= Kwarta Agad Lending Investor =========";
    file << "\n\n";
    file << "\n\t\t CUSTOMER REPORT";
    file << "\n\n";
    file << "\n Customer Name     : " << name;
    file << "\n Amount   Loan     : " << principal;
    file << "\n Number of Months  : " << number_months;
    file << "\n Rate Per Month    : " << rate;
    file << "\n\n";
    file << fixed << setprecision(2);
    file << "\n Interest Rate is Php " << solve_rate;
    file.close();
    cout << "\n\n";
    system("pause");
}

No comments:

Post a Comment