我正试图为我妹妹找出一道数学题。因此,作为我自己的一个小项目,我正在尝试编写一个程序来解决这个问题。目标是找出您成为百万富翁时的年龄。它看起来不错,但它没有产生任何东西。我什至无法将任何内容打印到屏幕上。它出什么问题了?我正在使用 C++。
int _tmain()
{
int age = 21, year = 1;
double salary, salaryIncrease, amountSaved, interestEarned,
total, totalMed;
salary = 38500, salaryIncrease = .10,
interestEarned = .045, amountSaved = .25, total = 0;
while (total < 1000000){
if (year % 3 == 0){
salary = salary * salaryIncrease + salary;
}
if (year = 10) interestEarned = .0525;
totalMed = salary * amountSaved;
total = (total + totalMed)*interestEarned;
age++;
year++;
}
cout << "Age = " << age << endl;
cout << "Total = " << total << endl;
cout << "hello?" << endl;
return 0;
}
最佳答案
if ( year = 10 )
需要
if( year == 10 )
关于c++ - 我在 visual studio 中的程序没有显示任何内容,我的代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34805050/