Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Retrieve CompoundInterestYourLastName (from Topic 3). Create a JUnit Test case to test your method. Write three tests using the data and results below. A hint:

  1. Retrieve CompoundInterestYourLastName (from Topic 3). Create a JUnit Test case to test your method. Write three tests using the data and results below.

    A hint: You can give your assertEquals method some leeway so you don't need the exact values by using this method:

    assertEquals(double expected, double actual, double delta); Asserts that two doubles or floats are equal to within a positive delta.

    If you ran your methods (with the main method without the printf( )), you'll see that you get several decimal points. One way that we can account for small differences is by giving the assertEquals method a delta - 0.01. This means that if the return result is within 0.01 of the expected value, return true. The assertion method would look something like:

    assertEquals(expected, actual, 0.01);

    Write assertion methods for the three examples below. Make sure that your assertion methods all pass.

    System.out.printf("Your total is $%.2f", computeBalance(10000, .045, 13));

    // should return $17721.96

    System.out.printf(" Your total is $%.2f", computeBalance(20000, .03, 15));

    // should return $31159.35

    System.out.printf(" Your total is $%.2f", computeBalance(30000, .01, 20));

    // should return $36605.70

    Pay close attention to your parameters to make sure they match the test data!

    When you are finished with your tests, upload and submit CompoundInterestYourLastName.java and CompoundInterestYourLastNameTest.java to Blackboard. This program is worth 20 points.

Here is my code: I need to Create a JUnit 5 Test case to test method. Write three tests using the data and results below. I need this to be in JUnit 5, not 4 or 3.

public class CompoundInterestSivakumar { public static double computeBalance(double balance, double annualInterestRate, int years) { double totalAmount = balance; double interest ; for(int i = 1 ; i <= years ; i++) { interest = totalAmount * annualInterestRate ; totalAmount += interest ; } return totalAmount ; } public static void main(String[] args) { System.out.printf("Your total is $%.2f", computeBalance(10000, .045, 13));

System.out.printf(" Your total is $%.2f", computeBalance(20000, .03, 15));

System.out.printf(" Your total is $%.2f", computeBalance(30000, .01, 20));

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

as HighPerforming (out of which

Answered: 1 week ago

Question

=+management system of the MNE?

Answered: 1 week ago