【发布时间】:2014-02-18 02:06:11
【问题描述】:
我有计算复利的代码,但我需要它在 1、3 和 5 年后执行此操作。我试过了,但似乎无法让它工作。谁能帮帮我?
import java.util.Scanner;
public class CompoundInterest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double principal = 0;
double rate = 0;
double time = 0;
double x = 0;
System.out.print("Enter the amount invested : ");
principal = input.nextDouble();
System.out.print("Enter the Rate of interest : ");
rate = input.nextDouble();
System.out.print("Enter the Time of loan : ");
time = input.nextDouble();
x = principal * Math.pow((1 + rate/12),time);
x = Math.pow(5,3);
System.out.println("");
System.out.println("The Compound Interest after 1 year is : "
+ x);
}
}
【问题讨论】:
标签: java math calculator rate