Compound interest Calculation--unit test

Source: Internet
Author: User

Scenario analysis, expected return values, and the following table of running results:

notes: Expected results 0.0 , which indicates that the input data is incorrect. That's not getting the right results.

Test module Test input Expected results Run results Bug tracking
Compound Interest Calculation (100,10,0.03) 134.39 That's right
Simple Interest Calculation (100,10,0.03) 130.0 That's right
Calculate Pre-Investment principal (100,10,0.03) 76.92 That's right
Calculate how many years after doubling (100,200,0.03) 23.44 That's right
Calculate interest rate (100,200,10) 0.073 That's right
Fixed by year (100,10,0.03) 1180.77 That's right
Monthly voting (100,10,0.03) 14169.35 That's right
Monthly principal and interest (100,10,0.03) 1.11 That's right

 PackageUnit;Import Staticorg.junit.assert.*;ImportOrg.junit.Assert;Importorg.junit.Test;Importbin.compounding; Public classTest {@SuppressWarnings ("Deprecation") @Test Public voidTest () {DoubleValue1=compounding.test_one (100, 10, 0.03); Assertequals (134.39, Value1, 0.1); DoubleValue2=compounding.test_two (100, 10, 0.03); Assertequals (130.0, Value2, 0.1); DoubleValue3=compounding.test_three (100, 10, 0.03); Assertequals (76.92, Value3, 0.1); DoubleValue4=compounding.test_four (100, 200, 0.03); Assertequals (23.44, Value4, 0.1); DoubleValue5=compounding.test_five (100, 200, 10); Assertequals (0.071, Value5, 0.1); DoubleVALUE6_1=COMPOUNDING.TEST_SIX1 (100, 10, 0.03); Assertequals (1180.77, Value6_1, 0.1); DoubleVALUE6_2=COMPOUNDING.TEST_SIX2 (100, 10, 0.03); Assertequals (14169.35, Value6_2, 0.1); DoubleValue7=compounding.test_seven (100, 10, 0.03); Assertequals (1.11, Value7, 0.1); }            }
     Public Static DoubleTest_one (DoubleAintBDoublec) {DoubleSum=a*math.pow (1 +C, B); returnsum; }     Public Static DoubleTest_two (DoubleAintBDoublec) {Doublesum=a*c*C; returnsum+A; }     Public Static DoubleTest_three (DoubleAintBDoublec) {Doublesingle=a/(1+b*c); returnSingle ; }     Public Static DoubleTest_four (DoubleADoubleBDoublec) {DoubleYears=math.log (b/a)/math.log (1 +c); returnyears; }     Public Static DoubleTest_five (DoubleADoubleBintc) {DoubleR=math.pow ((b/a), 1/c)-1; returnR; }     Public Static DoubleTEST_SIX1 (DoubleAintBDoublec) {Doublesum=a* (1+c) * ( -1+math.pow (1+c, B))/C; returnsum; }     Public Static DoubleTEST_SIX2 (DoubleAintBDoublec) {Doublesum=a*12* (1+c) * ( -1+math.pow (1+c, B))/C; returnsum; }     Public Static DoubleTest_seven (DoubleAintBDoublec) {DoubleSum=a*math.pow (1 +C, B); DoubleMonthmoney=sum/b/12; returnMonthmoney; }

Compound interest Calculation--unit test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.