//Because the C language version is not convenient unit test, so changed to Java version, part of the code is as follows:
ImportJava.util.Scanner; Public classfuli{ Public Static voidMain (string[] args) {Scanner Scanner=NewScanner (system.in); System.out.println ("\ n Compound interest calculated by 1\n simple interest calculated by 2\n calculated according to the 3\n calculation time according to 4\n calculate your interest rate according to 5\n calculation Benli and investment according to 6\n calculation of equal and principal repayment by 7\n\n); intC=Scanner.nextint (); if(c==1) {System.out.println ("Enter your principal:"); DoubleMoney =NewScanner (system.in). nextdouble (); System.out.println ("Enter your desired annual interest rate:"); DoubleRate =NewScanner (system.in). nextdouble (); System.out.println ("Enter your desired deposit period (years):"); intYear =NewScanner (system.in). Nextint (); Doubleresult=money* (1+rate*Year ); System.out.println ("The result is:" +result); } if(c==2) {System.out.println ("Enter the amount you need to raise:"); DoubleFuturemoney =NewScanner (system.in). nextdouble (); System.out.println ("Enter your desired deposit period (years):"); intYear =NewScanner (system.in). Nextint (); System.out.println ("Enter your desired interest rate:"); DoubleRate =NewScanner (system.in). nextdouble (); Doubleresult = futuremoney/(1+rate*Year ); System.out.println ("The principal you need to deposit is:" +result); } } }
I also carried out the unit tests for these two functions. The first is the test of compound interest calculation. The running results and test results are as follows:
Then the second Test, which is about raising pensions, runs the results and tests the results as follows:
Compounding 5.0 (change to Java version) and unit test