1 ImportJava.util.Scanner;2 3 Public classFulijisuan {4 5 Public Static voidMain (string[] args) {6 //TODO auto-generated Method Stub7 DoubleN=1;8Scanner scanner=NewScanner (system.in);9System.out.print ("To calculate the principal, press 3 otherwise press 0:");Ten intnum=scanner.nextint (); One if(num==3){ A DoubleMoney ; - floatYear=30; - floattotal=3000000; the Doublea=0.30; - for(intj=1;j<=year;j++){ -n= (1+a) *N; - } +money=total/N; -SYSTEM.OUT.PRINTLN ("required Principal:" +Money ); + } ASystem.out.print ("Please select compound calculation (1) or simple interest Calculation (2):"); at intChoose=scanner.nextint (); - -System.out.print ("Please enter the principal:"); - floatp=scanner.nextint (); -System.out.print ("Please enter interest rate:"); - floatI=scanner.nextfloat (); inSystem.out.print ("Deposit Time:"); - floatn=scanner.nextfloat (); to + if(choose==1){ - Fuli (n, P, I, n); the } * Else if(choose==2){ $ Danli (P, i,n);Panax Notoginseng } - the } + A Private Static voidDanli (DoublePDoubleIDoubleN) { the DoubleG; + -g=p+p*i*N; $System.out.print ("Simple Interest End value:" +G); $ } - - Private Static voidFuli (DoubleNDoublePDoubleIDoubleN) { the for(intj=1;j<=n;j++){ - Wuyin= (1+i) *N; the } - DoubleF; Wuf=p*N; -System.out.print ("End value of compounding:" +F); About } $ - -}
Compound Interest Calculation