Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 1 Day Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
 can someone add to this code so that it will output to a file? I am working with Xcode.
#include <iostream>
#include <iomanip>
using namespace std;
#include <cmath>
int main()
{
  // variables declared
  float TOTAL_LOANAMOUNT = 22500.00; //loan amount
  float INTEREST = 5.37; // interest rate
  int YEARS = 8; // loan period
  int TAX = 350;
  float monthInterest;
  float payment;
  int paymentsPeriod = YEARS * 12;
 Â
  cout<<"Month"<<"Interest rate"<<"EMI "<<"Tax "<<" Balance"<<endl;
  for(int i=0;i<paymentsPeriod;i++){
     monthInterest = (INTEREST / 100) / 12;
     payment = (TOTAL_LOANAMOUNT * pow(monthInterest + 1, paymentsPeriod) * monthInterest)/(-1 + pow(monthInterest + 1,paymentsPeriod) );
     if(i%12 == 0 && i>0){
        payment = payment + TAX;
     }
     payment = payment;
     cout<<(i+1)<<" $"<<monthInterest<<" $"<<payment<<" $"<<TAX<<" $"<<TOTAL_LOANAMOUNT<<endl;
     TOTAL_LOANAMOUNT = TOTAL_LOANAMOUNT- payment;
  }
  return 0;
}
Â