-4
这个程序计算前6个月的利息给定量,它不工作的错误在哪里?程序来计算利息
import java.util.Scanner;
public class BalAfter6Months{
public static void main(String []args){
int counter=1;
double interest,SavBal,total,amount;
Scanner sc = new Scanner (System.in);
System.out.print("Enter the monthly saving amount: ");
amount = sc.nextDouble();
SavBal = amount;
while (counter<7) {
interest = amount * 0.00417;
total = interest + SavBal;
amount = amount + SavBal;
counter++;
}
System.out.print(total);
}
}
你应该告诉我们你得到了什么以及你的期望。 – Arc676
欢迎来到StackOverflow。请访问[帮助]并阅读[问]。形式问题“这里是我的代码,它不起作用,请告诉我什么是错误的”在这里通常被认为是脱离主题。你必须解释什么不起作用(显示预期的和实际的输出)并解释你已经完成的调试。 –
那么如果你的意思是它不能编译,试着初始化总数' – MartinS