| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1468 人关注过本帖
标题:如何改正错误
只看楼主 加入收藏
lyy0012345
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-11-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
如何改正错误
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(9,6): error C2371: “month”: 重定义;不同的基类型
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(8): message : 参见“month”的声明
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(26,11): error C2088: “<<”: 对于 class 非法
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(33,12): error C2088: “<<”: 对于 class 非法
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(36,42): error C2088: “<<”: 对于 class 非法
1>C:\Users\Administrator\source\repos\ConsoleApplication5\ConsoleApplication5\ConsoleApplication5.cpp(37,95): error C2088: “<<”: 对于 class 非法
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
    double loanamount; double annualinterestrate; double monthlypayment; double month; double currentfacevalue;  double interest; double repaidPrincipal;
    int month = 1;
    cout << "" << endl;
    cout << "Welcome to the Personal Loan System" << endl;
    cout << "========================================================================================================================" << endl;
    cout << "" << endl;
    cout << "Please enter the loan amount:";
    cin >> loanamount;
    cout << "Please enter the annual interestrate(%):";
    cin >> annualinterestrate;
    cout << "Please enter the monthlypayment:";
    cin >> monthlypayment;
    cout << "" << endl;
    cout << "Month"  << setw(20) <<"Current face value" << setw(20) << "Interest"  << setw(25) << "Repaid Principal" << endl;
    cout << "================================================================================================================" << endl;
    currentfacevalue = loanamount;
    interest = loanamount * annualinterestrate * 1 / 1200;
    repaidPrincipal = monthlypayment - interest;
    cout <<""<< month << setw(20) << "$" << currentfacevalue << setw(20) << "$" << interest << setw(25) << "$" << repaidPrincipal << endl;
    while (currentfacevalue >= repaidPrincipal)
    {
        month += 1;
        currentfacevalue -= repaidPrincipal;
        interest = loanamount * annualinterestrate * 1 / 1200;
        repaidPrincipal = monthlypayment - interest;
        cout <<""<< month << setw(20) << "$" << currentfacevalue << setw(20) << "$" << interest << setw(25) << "$" << repaidPrincipal << endl;
        if (currentfacevalue < repaidPrincipal)
        {
            cout << "Remaining Balance in month " << month << "=" << currentfacevalue << endl;
            cout << "(Note: The remaining balance" << currentfacevalue << "with settled in the month " << month << "!)";
        }
    }
搜索更多相关主题的帖子: cout double Users cpp the 
2020-11-07 13:02
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9031
专家分:54061
注 册:2011-1-18
收藏
得分:20 
你重复定义了 month 等
既有 double month
又有 int month = 1
2020-11-07 14:34
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9031
专家分:54061
注 册:2011-1-18
收藏
得分:0 
代码我看不懂,只是帮你改了错误

程序代码:
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main()
{
    cout << "\nWelcome to the Personal Loan System\n"
            "========================================================================================================================\n\n";

    double loanamount;
    cout << "Please enter the loan amount:";
    cin >> loanamount;

    double annualinterestrate;
    cout << "Please enter the annual interestrate(%):";
    cin >> annualinterestrate;

    double monthlypayment;
    cout << "Please enter the monthlypayment:";
    cin >> monthlypayment;

    cout << "\nMonth" << setw(20) << "Current face value" << setw(20) << "Interest"  << setw(25) << "Repaid Principal\n";
    cout << "================================================================================================================" << endl;
 
    int month = 1;
    double currentfacevalue = loanamount;
    double interest = loanamount * annualinterestrate * 1 / 1200;
    double repaidPrincipal = monthlypayment - interest;
    cout << month << setw(20) << "$" << currentfacevalue << setw(20) << "$" << interest << setw(25) << "$" << repaidPrincipal << endl;

    while (currentfacevalue >= repaidPrincipal)
    {
        month += 1;
        currentfacevalue -= repaidPrincipal;
        interest = loanamount * annualinterestrate * 1 / 1200;
        repaidPrincipal = monthlypayment - interest;
        cout << month << setw(20) << "$" << currentfacevalue << setw(20) << "$" << interest << setw(25) << "$" << repaidPrincipal << endl;
        if (currentfacevalue < repaidPrincipal)
        {
            cout << "Remaining Balance in month " << month << "=" << currentfacevalue << endl;
            cout << "(Note: The remaining balance" << currentfacevalue << "with settled in the month " << month << "!)";
        }
    }
}
2020-11-07 14:46
快速回复:如何改正错误
数据加载中...
 
   



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

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