Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class BookOrderYourlastname { static double order_total(int number_of_books,int subtotal){ double total_bill=0,shipping_cost=0,total_tax=0; shipping_cost=2.75*number_of_books; total_tax=0.12*subtotal; total_bill=shipping_cost+total_tax+subtotal; return total_bill; } public static void main(String[] args) {

import java.util.Scanner;

public class BookOrderYourlastname { static double order_total(int number_of_books,int subtotal){ double total_bill=0,shipping_cost=0,total_tax=0; shipping_cost=2.75*number_of_books; total_tax=0.12*subtotal; total_bill=shipping_cost+total_tax+subtotal; return total_bill; } public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int number_of_books, subtotal; System.out.println("Enter the number of books"); number_of_books = sc.nextInt(); System.out.println("Enter the subtotal"); subtotal = sc.nextInt(); double total_bill = order_total(number_of_books, subtotal); System.out.println("The total_bill is :" + total_bill);

LANGUAGE = JAVA

Online Book Order (method)

Retrieve BookOrderYourLastName (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( ) 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.

Test Data #1 Test Data #2

Enter the number of books purchased: 5

Enter the book order subtotal: 68.45

Number of books purchased: 5

Book Subtotal: $68.45

------------------------

Order Total: $79.71

Enter the number of books purchased: 8

Enter the book order subtotal: 125.37

Number of books purchased: 8

Book Subtotal: $125.37

------------------------

Order Total: $144.27

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago