【发布时间】:2014-02-03 23:26:00
【问题描述】:
嘿,我是编码新手,想知道你们是否可以帮助我计算不同的利率,然后将它们添加到下一个利率。所以基本上我试图获得利率 A 并将其添加到 100 的起始值。然后我想获得 100 的利率 B 并将该值添加到利息 A。到目前为止,这是我的代码,但我得到了 10 行对于每个利率。抱歉,如果这听起来令人困惑,但希望代码能让它更清晰,或者如果阅读本文的人愿意,我可以尝试更好地解释。谢谢!!
int intv;
cout << " Accumulate interest on a savings account. ";
cout << " Starting value is $100 and interest rate is 1.25% ";
cout << endl;
intv = 100;
index = 1;
while ( index <= 10 )
{
cout << " Year " << index << " adds 1.25% for a total of " << .0125 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.27% for a total of " << .0127 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.28% for a total of " << .0128 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.30% for a total of " << .0130 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.31% for a total of " << .0131 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.32% for a total of " << .0132 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.35% for a total of " << .0135 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.36% for a total of " << .0136 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.38% for a total of " << .0138 * intv + intv << "." << endl;
cout << " Year " << index << " adds 1.40% for a total of " << .0140 * intv + intv << "." << endl;
index = index + 1;
}
我只需要提示,而不是为我这样做。我想自己解决这个问题,但我不知道我必须做什么。
程序的理想结果是给我这个:
第 1 年增加 1.25,总共 101.25 第 2 年增加 1.27,总共 102.52 第 3 年增加 1.28,总计 103.80 第 4 年增加 1.30,总共 105.09 第 5 年增加 1.31,总计 106.41 第 6 年增加 1.33,总共 107.74 第 7 年增加 1.35,总共 109.09 第 8 年增加 1.36,总共 110.45 第 9 年增加 1.38,总计 111.83 第 10 年增加 1.40,总计 113.23
贷记的总利息为 13.23
【问题讨论】:
-
为您的问题添加更多标签。我不确定这是什么语言,所以这将是一个有用的标签! ;-)
-
对不起。它在 C++ 中,我正在使用 Visual Studio 2012
-
没有问题!标签只是帮助您获得更多回复,因为人们喜欢查看他们擅长的问题。
-
如果你给我一个你想要的输出示例,我敢打赌我几乎可以为你编写代码。 (虽然我不懂 C++!)
-
好吧,我们可以帮助您解决您遇到的任何问题,但我们不会为您解决您的作业。试一试,当你遇到一些错误时编辑你的帖子
标签: c++ calculator