我很难解决这个问题。我需要创建一个循环重复5次。该循环需要取整数x并乘以0.2并显示结果。然后它需要取得这个结果并且乘以0.2并显示结果。它需要做5次。循环显示一个数字增加0.2%5次
float credithours;
float tuition = 274.41;
cout << "How many credit hours are you taking this semester? " << endl;
cin >> credithours;
cout << "Your current semester tuition is " << credithours * tuition << endl;
float tuitionfive = credithours * tuition * 2;
cout << "Your tuition for the year is " << tuitionfive << endl;
float tuitiontotal = (tuitionfive * .2) + (tuitionfive);
for (float x = 1; x <= 5; x++) {
x = tuitiontotal * .2 + tuitionfive;
cout << x << endl;
}
编辑*****
我在这里固定的帮助后的代码,这是最终的结果:
float credithours;
float tuition = 274.41;
cout << "How many credit hours are you taking this semester? " << endl;
cin >> credithours;
float semestertuition = credithours * tuition;
cout << "Your current semester tuition is " << semestertuition << endl;
float tuitionfive = semestertuition * 2;
cout << "Your tuition for the year is " << tuitionfive << endl;
cout << "Your tuition for the next 5 years is: " << endl;
for (int i = 0; i < 5; ++i)
{
tuitionfive = tuitionfive * .2 + tuitionfive;
cout << tuitionfive << endl;
}
我没有使用指数然而,正如我需要做更多的研究来更多地理解它。再次感谢您的帮助。
那么,是你的码?除了问这里之外,你实际上做了什么来解决你的问题? – Kupto
我刚添加了代码。编辑我的原始帖子。我得到了循环重复5次,我只是不知道如何输入数学方程,所以方程重复5次。 – AMD