-3
我有這個計算複利的代碼,但我需要它在1年,3年和5年後進行。香港專業教育學院試圖和不能似乎得到它的工作。誰能幫我?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);
}
}
http://qrc.depaul.edu/studyguide2009/notes/savings%20accounts/compound%20interest.htm – OldProgrammer