Java语言程序设计基础篇_第十版_梁勇题目:(财务应用程序)复利值
package nameyu;import java.util.Scanner;public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); System.out.print("Enter the monthly saving amount and mouth:"); double save=input.nextDouble(); int mouths=input.nextInt(); double yearsrate=0.05; double mouthrate=(yearsrate/12); double total=0; for(int i=1;i<=mouths;i++){ total=(total+save)*(1+mouthrate); } System.out.println((int)(total*100)/100.0); }}
页:
[1]