Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Jul 2017 |
Last Sign in: | 210 Weeks Ago, 2 Days Ago |
Questions Answered: | 15833 |
Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
loan calculator in C++, I need to add the ability to save data to a disk in one or more files. The menu(s) should give the user the option to save or retrieve data. This is my code so far.
Â
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
int main()
{
float Principal;
float Interest;
int Months;
float AccInterest;
float monPayment;
float appPrincipal;
float endBalance;
cout << "Welcome to the loan calculator!" << endl;
cout << "Please enter the amount of your loan: ";
cin >> Principal;
cout << "Please enter the interest rate: ";
cin >> Interest;
cout << "please enter the amount of months the loan is for: ";
cin >> Months;
for (int x = 0; x < Months; x++)
{
AccInterest = (Principal) * (Interest / 100) / 12;
monPayment = (Principal * (Interest / 100) / 12) * (pow(1 + (Interest / 100) / 12, Months) / (pow(1 + (Interest / 100) / 12, Months) - 1));
appPrincipal = monPayment - AccInterest;
endBalance = Principal - monPayment + AccInterest;
cout << "Month " << x + 1 << " of " << Months << endl;
cout << "Starting Principal: $" << Principal << endl;
cout << "Payment is: $" << monPayment << endl;
cout << "Accured interest is: $" << AccInterest << endl;
cout << "Applied to Principal is: $" << appPrincipal << endl;
cout << "End balance: $" << endBalance << endl;
Principal -= appPrincipal;
cin.get();
}
return 0;
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly