| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1355 人关注过本帖
标题:error: expected ')'
只看楼主 加入收藏
memepapa
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-12-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
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
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9029
专家分:54050
注 册:2011-1-18
收藏
得分:20 
while (choice! = -99)
改为
while (choice != -99)

cin << choice;
改为
cin >> choice;

int choice;
改为
int choice = 0;
2021-12-28 13:27
memepapa
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-12-28
收藏
得分:0 
回复 2楼 rjsp
谢谢指导,感激
2021-12-28 18:37
快速回复:error: expected ')'
数据加载中...
 
   



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

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