Question: Java, modify code so that Tests with Junit can be added Retrieve BookOrderYourLastName (from Topic 3). that code is: import java.text.DecimalFormat; import java.util.Scanner; public class
Java, modify code so that Tests with Junit can be added
Retrieve BookOrderYourLastName (from Topic 3).
that code is:
import java.text.DecimalFormat; import java.util.Scanner; public class BookOrderYourLastName { public static void main (String[]args) { DecimalFormat df = new DecimalFormat("##.00"); System.out.println("Enter the amount of books purchased:"); Scanner in = new Scanner(System.in); int book = in.nextInt(); int bookprice = 15; int Sub = book * bookprice; double tax = .055 * Sub; double ship = 1.50 * book; double total = Sub + tax + ship; System.out.println("Number of books purchased: " + book); System.out.println("Book Subtotal: $" + Sub); System.out.println("Tax: $" + tax); System.out.println("Shipping: $" + ship); System.out.println("_________________"); System.out.println("Order Total: $" + total); } } 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( ) or DecimalFormat), 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); Create a JUnit test case to test your newly created method. Use the test data below to confirm you are receiving the correct values.

Both files are worth 10 points, upload both to blackboard.
Test Data #1 Test Data #2 Enter the number of books purchased: 5 Enter the number of books purchased: 8 Enter the book order subtotal: 68.45 Enter the book order subtotal: 125.37 Number of books purchased: 5 Number of books purchased: 8 Book Subtotal: $68.45 Book Subtotal: $125.37 Order Total: $79.71 Order Total: $144.27
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
