Menu

Having trouble w/ my program

2008-12-04
2012-09-26
  • Chris  Benitez

    Chris Benitez - 2008-12-04

    Well I'm not sure if my source code is missing anything, or if i'm just using the Dev-C++ incorrectly, but I'm writing a code that compounds interest yearly. When running the program the command window pops up VERY briefly and closes. I don't even get to see the values. What do you guys suggest? All I have in my project is the source code ( here, just in case I missed something in my code)

    // Calculating compound interest.

    include <iostream>

    using std::cout;
    using std::endl;
    using std::ios;
    using std::fixed;

    include <iomanip>

    using std::setw;
    using std::setprecision;

    include <cmath>

    int main()
    {
    double amount, principal = 1000.0;
    double rate = .05;

    cout&lt;&lt;&quot;year&quot;&lt;&lt;setw(21)&lt;&lt;&quot;amount on deposit&quot;&lt;&lt;endl;
    
    // set floating-point number format
    cout &lt;&lt; fixed &lt;&lt; setprecision(2);
    
    //calculate amount on deposit for each of ten years 
    for ( int year = 1; year &lt;= 10; year++ )
    {
        //calculate new amount for specified year 
        amount = principal * pow(1.0+rate, year);
    
        //output one table row
        cout &lt;&lt; setw(4) &lt;&lt; year &lt;&lt; setw(21) &lt;&lt; amount &lt;&lt; endl;
     } // end for
    

    }

     
    • cpns

      cpns - 2008-12-04

      > What do you guys suggest?

      sigh I suggest reading the "PLEASE READ BEFORE POSTING A QUESTION" thread. It answers this exact question. It is normal behaviour when a program terminates that its Window should close, but people remain surprised when it happens to their programs.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.