ok this is the word problem
Hulk Hogan invests in a Roth IRA. He plans to put $200 in the account on the first of each month, beginning on Jan 1, 2007. His last payment will be on Dec 1, 2036. His money earns a (% annual interest rate, compounded monthly. Calculate and print his balance on January 1 of each year, from 2007 until 2037. Do not print the other months.
this is wut i have so far
//this program calculates the 9% annual interest
//of an IRA account compounded monthly then prints
//out every january 1st for 30 years.
#include %26lt;iostream%26gt;
#include %26lt;iomanip%26gt;
#include %26lt;cmath%26gt;
using namespace std;
int main()
{
cout%26lt;%26lt;"This is the program of : ";
cout%26lt;%26lt;"Dillon Nicholson"%26lt;%26lt;"\n";
cout%26lt;%26lt;"CMPS 1043-02"%26lt;%26lt;"\n";
cout%26lt;%26lt;"Due date:";
cout%26lt;%26lt;" Oct 30 2007"%26lt;%26lt;"\n"%26lt;%26lt;"\n";
double principal = 200.00;
double amount;
double rate = (1 + .09/12) * 12;
cout %26lt;%26lt; "January 1st of year" %26lt;%26lt; setw( 21 ) %26lt;%26lt; "Amount on deposit" %26lt;%26lt;endl;
cout %26lt;%26lt; fixed %26lt;%26lt; setprecision( 2 );
Still need c++ help?
to print some thing in a file, do this:
//add the library of file
#include%26lt;fstream%26gt;
//initialize an output file
ofstream out; // or any other name like outFile
//open the file
out.open("SomeFileName.SomeFormat") //like out.open("output.txt")
//then use out instead of cout in any line like replace this
cout %26lt;%26lt; "January 1st of year" %26lt;%26lt; setw( 21 ) %26lt;%26lt; "Amount on deposit" %26lt;%26lt;endl;
cout %26lt;%26lt; fixed %26lt;%26lt; setprecision( 2 );
//replace above with
out %26lt;%26lt; "January 1st of year" %26lt;%26lt; setw( 21 ) %26lt;%26lt; "Amount on deposit" %26lt;%26lt;endl;
out %26lt;%26lt; fixed %26lt;%26lt; setprecision( 2 );
//this way the result is printed in a file
//finally close the file
out.close()
Reply:Look carefully at your pow() function call. You're adding 1.00 to rate, but rate already had a 1 factored in back when it was defined.
Note that I'm hardly up on compound interest enough to verify your overall calculations.
Hope that helps.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment