通货膨胀率计算器
inflation rate calculator c++
我试图建立一个通货膨胀率计算器,但它不工作。我现在不在国内,用的是学校的电脑,所以所有的错误都是韩文,我已经翻译了,但不是很明白。
#include <iostream>
using namespace std;
double inflationRate (double startingPrice, double currentPrice);
int main()
{
double startingPrice, currentPrice;
char again;
do
{
cout << "enter the price of the item when you bought it: ";
cin >> startingPrice;
cout << "enter the price of the item today: ";
cin >> currentPrice;
cout << "the inflation Rate is: " << inflationRate(startingPrice, currentPrice) << "%";
cout << "would you like to try another item (y/n)?";
cin >> again;
}while((again == 'Y') || (again =='y'));
return 0;
}
double inflationRate(double startingPrice, double currentPrice)
{
return ((currentPrice - startingPrice) / startingPrice);
}
1> ------ Build started: Project: testing, configuration: Debug Win32 ------
1> Build started: 2016-09-22 11:04:39 AM
1> InitializeBuildStatus:
1> "Debug testing. "a.
1> ClCompile:
1>所有输出都是最新的
1> ManifestResourceCompile:
1>所有输出都是最新的
1> LINK: fatal error LNK1123:转换到COFF时发生错误。或损坏的文件不正确。
1>
1>创建失败。
1>
1>运行时间:00:00:00.08
========== 构建:0成功,1失败,最新的0,0跳过 ==========
您正在声明一个无用的变量inflationRate
而不是调用函数inflationRate
。我认为这是你想要的(我假设第一行缺失的#
是复制粘贴错误):
#include <iostream>
using namespace std;
double inflationRate (double startingPrice, double currentPrice); // <-- Missing semicolon!
int main() // <-- Not void; use int.
{
double startingPrice, currentPrice; // <-- Removed inflationRate variable.
char again;
do
{
cout << "enter the price of the item when you bought it: ";
cin >> startingPrice;
cout << "enter the price of the item today: ";
cin >> currentPrice;
cout << "the inflation Rate is: " << inflationRate(startingPrice, currentPrice) << "%"; // <-- Calling inflationRate
cout << "would you like to try another item (y/n)?";
cin >> again;
}while((again == 'Y') || (again =='y'));
return 0;
}
double inflationRate(double startingPrice, double currentPrice)
{
return ((currentPrice - startingPrice) / startingPrice);
}
相关文章:
- 哪些库可以通过Opencv调整曝光率
- 使用 BMI 计算器对C++中的数字进行四舍五入的问题
- 如何在qt中同步应用程序和显示器的刷新率?
- 我在c ++矩阵计算器程序中找不到错误
- C++计算器,不能单独除以 0
- 如何正确解析子字符串,以便它们对我的新手计算器有效?
- Arduino 基础 2 计算器无法C++工作
- 需要有关我的平均计算器代码的建议
- C++ - 在我尝试制作一个简单的计算器时有一个"uninitialized local variable y used"警告
- 野牛/flex:计算器将双精度值解释为整数,所以我添加了 YYSTYPE 双精度 #define 但我有多个编译错误
- C++计算器运算符
- 如何从wav文件中获取采样率?
- 如何提高 OpenCV 实时检测器应用程序的帧率?
- 使用WIN32 API的击球平均计算器
- 在 directx11 代码中更改全屏模式下的刷新率不起作用
- C++ 如何设置精确的帧率限制?
- 媒体基金会:WavSink以比实时消耗率更快的速度处理音频-是否可以实时限制后台处理
- RPN计算器c++错误处理和多个运算符
- 通货膨胀率计算器
- 衡量 C++ 的通货膨胀率