标题:error: expected ')'
取消只看楼主
memepapa
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-12-28
结帖率:0
已结贴  问题点数:20 回复次数:1 
error: expected ')'
这是我在网上找到的一个 C++ 计算 compound interest 的代码,应该是比较旧版的,所以我 compile 时出现了以下错误


error: expected ')'
    while (choice! = -99)
                 ^
note: to match this '('
    while (choice! = -99)


请问谁能指导我怎么处理修改吗?

下面是完成的代码




#include <iostream>

#include <stdlib.h>

#include <cmath>

using namespace std;

double simple_interest (double principal, double rate, double time);

double compound_interest (double principal, double rate, double time);

double compound_interest_ear (double principal, double rate, double time, double period);

int main ()
{

    double amount, principal, rate, time, interest, R;

    int choice;

    double SI, CI, EAR, Amount, period;

    amount = principal = rate = time = interest = 0.0;

    while (choice! = -99)
    {

        cout << "\n\n\n\n\n";

        cout << "\t\t\tEnter Principal amount:"; cin >> principal;

        cout << "\t\t\tEnter Rate (In percentage):"; cin >> R;

        rate = R/100;

        cout << "\t\t\tEnter Time (In Years):"; cin >> time;

        cout << "\t\t\t" << principal << endl;

        cout << "\t\t\t" << rate << endl;

        cout << "\t\t\t" << time << endl;

        cout << "\t\t\t************ MENU ********************" << endl;

        cout << "\t\t\t1: Simple Interest" << endl;

        cout << "\t\t\t2: Compound Interest" << endl;

        cout << "\t\t\t3: Effective Annual Rate (Compound Interest)" << endl;

        cout << "\t\t\t****************************************" << endl;

        cout << "\t\t\tEnter You Choice:"; cin >> choice;

        if(choice == 3)
        {

            cout << "\t\t\tNo of Period in a Year:";
            cin >> period;

        }

    switch(choice)
    {

        case 1:

            SI = simple_interest (principal, rate, time);

            Amount = principal + SI;

            cout << "\n\n\n";

            cout << "\t\t\tSimple Interest =" << " "<< SI << endl;

            cout << "\t\t\tTotal Amount =" << " " << Amount<< endl;

            break;

        case 2:

            Amount = compound_interest(principal, rate, time);

            CI = Amount - principal;

            cout << "\n\n\n";

            cout << "\t\t\tCompound Interest with Principal =" << " "
            <<
            Amount << endl;

            cout << "\t\t\tTotal Compound Interest ="<< " " <<
            CI << endl;

            break;

        case 3:

            Amount = compound_interest_ear(principal, rate, time, period);

            CI = Amount - principal;

            EAR = pow((1 + (rate/period)),period)-1;

            cout << "\n\n\n";

            cout << "\t\t\tCompound Interest with Principal =" << " " <<
            Amount << endl;

            cout << "\t\t\tTotal Compound Interest =" << " " <<
            CI << endl;

            cout << "\t\t\tEffective Annual Rate =" << " " <<
            EAR << endl;

            cout << "\t\t\tNomianal Rate =" << " " <<
            rate << endl;

            break;

        default:

            cout << "\t\t\tSorry ! Try again";

            break;

        }

    cout << "\n\n\n";

    cout << "\t\t\tDo you want to Continue?" << endl;

    cout << "\t\t\tEnter -99 to end" << endl;

    cout << "\t\t\tOr Enter any other number to Continue:";
    cin << choice;

    }

    system("PAUSE");

    return EXIT_SUCCESS;

}

// Simple interest

double simple_interest(double principal, double rate, double time)
{

    double SI = principal * rate * time;

    double Amount = principal + SI;

    return SI;

}

// Compound Interest

double compound_interest(double principal, double rate, double time)
{

    double CI;

    double Amount;

    Amount = principal * pow((1 + rate),time);

    return Amount;

}

// Compound Interest with the effective annual rate

double compound_interest_ear(double principal,double rate, double time,double period)
{

    double CI, EAR, Amount;

    period = period * time;

    Amount = principal * pow((1 + (rate/period)),period);

    return Amount;

}


搜索更多相关主题的帖子: time choice cout double amount 
2021-12-28 11:08
memepapa
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-12-28
得分:0 
回复 2楼 rjsp
谢谢指导,感激
2021-12-28 18:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-508020-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.532011 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved