现存入10000元,编写一个程序,计算假设存一年、两年、三年或五年,
到期取款时,银行应支付的本息分别是多少。
利息 = 本金年利率存期 本息=本金+利息
double principal = 10000;
double rate = 0.05; // 年利率为 5%
for (int years = 1; years <= 5; years++) {
double interest = principal * rate * years;
double principalAndInterest = principal + interest;
System.out.printf("存%d年,本息总额为: %.2f\n", years, principalAndInterest);
}