Test of compound Interest Calculation 1

Source: Internet
Author: User

Test module Data Forecast results Input data Error results Error handling
1. Principal and interest

Principal blank

Interest rate blank
Number of years blank
The principal is 0
Interest rate is 0
The number of years is 0
Interest rate greater than 1
The principal is infinitely large
2. Principal Principal and interest is 0
Interest rate is 0
The number of years is 0
The principal interest is very large
1  Public DoubleCalculatea (DoubleYears2,intN2,DoublePrincipal2,Doublerate2) {2         DoubleAmount2 = 0;3          while(Years2 <=n2) {4             /*amount = Principal * MATH.POW (1 + rate, year);5 Output + = string.valueof (year) + "\ T" + currencyformatter.format (amount) + "\ n";6 Year = year + 1;*/7Amount2 = Principal2 * MATH.POW (1 +Rate2, years2);8                    9             TenYears2 = years2 + 1; One         } A         returnAmount2; -}

The previous code has not been marshaled, which is the function of the principal and interest package, but not when testing

1  Public class atest {23    @Test4public     void  Test () {5         double a=new fuli1 (). Calculatea (1, 3, 10000, 0.03); 6         Assertequals (10927.27, a); 7     }89 }

Reason for error:Assertequals supports Boolean,long,int and so on Java primitivetype variables.

1  Public classatest {2 3     4 @Test5      Public voidTest () {6         DoubleA=NewFuli1 (). Calculatea (1, 3, 10000, 0.03);7         Booleanflag=0.0==a-10927.27;8Assertequals (true, flag);9}

Not very familiar with testing, looking for other resources in learning

There are other predictions that are being tested, which are only part of the

Second, summary

For this quiz, I think my previous code is a mess, all are squeezed together so that I can not understand their own ideas, through the test, I am slowly learning to make up a clear structure of the program

Test of compound Interest Calculation 1

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.