ㄚ源 asked in 電腦與網際網路軟體 · 1 decade ago

C++程式題目

請用Dev c++解下列題目:

某人在銀行存入50萬,利率是4%,如果每年的利息都繼續存入銀行,即複利,請設計計算在10年後本金加利息一共有多少錢?

P.S 因為複利的部分我怎麼想都想不出來,所以上來問一下

還有希望盡量程式寫簡單明瞭,因為我程度不是很好^^

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    #include<iostream>

    using namespace std;

    int main()

    {

    float money = 500000; //ㄧ開始存入的50萬

    float rate = 0.04; //年利率4%

    float sum ;

    //本題的複利總和為 50000*(1+0.04)^10

    sum = 1;

    for( int x = 0 ; x < 10 ; x++ )

    {

    sum = sum * ( 1 + rate );

    } // 計算(1+0.04)^10

    money = money * sum;

    cout<<"10年後的錢為:"<<money<<endl;

    system("pause");

    return 0 ;

    }

    Source(s): myself+數學公式
    • Login to reply the answers
  • 1 decade ago

    #include <iostream>

    using namespace std;

    int main()

    {

    float money = 500000;

    float x=0.04;

    float n=1;

    for(int i=0;i<10;i++)

    {

    n=n*(1+x);

    }

    money = money*n;

    cout<<money;

    system("PAUSE");

    return 0;

    }

    • Login to reply the answers
Still have questions? Get your answers by asking now.