我有以下代码来运行复合兴趣程序,但我不知道它为什么不起作用。 Eclipse给我的错误消息:“本地变量的数量没有使用。”复合兴趣程序语法错误
package loops;
public class CompoundInterest {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("How much did you put into the bank?");
double deposit = IO.readDouble();
System.out.println("What is the bank's interest rate?");
double rate = IO.readDouble();
System.out.println("How many times will it compound?");
double compound = IO.readDouble();
System.out.println("How many years?");
double years = IO.readDouble();
for (int i = 1; i<=20; i++){
double amount = deposit * Math.pow(1+(rate/compound), years*compound);
}
}
}
由于你从来没有产生任何输出,它警告你,你的计算都是浪费电子运动。 – bmargulies
是的,我刚刚意识到这一点。谢谢。 – Chris
为什么你重复完全相同的计算20次?使用你用过的公式就意味着你只需要做一次计算。 –