Question
The following pseudocode describes how a bookstore computes the price of an order from the total price and the number of the books that were
The following pseudocode describes how a bookstore computes the price of an order from the total price and the number of the books that were ordered.
- Read the book subtotal (the price of all the books added together) and the number of books.
- Compute the tax (5.5 percent of the total book price).
- Compute the shipping charge ($1.50 per book).
- The price of the order is the sum of the total book price, the tax, and the shipping charge.
- Print the price of the order.
Translate this pseudocode into a Java program. Create a variable (probably a double) with the book subtotal and a variable for the number of books (probably an int since you can't have a decimal points worth of books). Use these variables to compute the tax and shipping charge. Assume that the tax rate and shipping charge will always stay constant. Sum the results of the variables together. Finally, print all the variables out with labels like the receipt show below. Remember to change the values in your variables and test after you've finished your program to make sure it works correctly.
Test Data #1 | Test Data #2 |
Number of books purchased: 5 Book Subtotal: $68.5 Tax: $3.7675 Shipping: $7.5 ------------------------ Order Total: $79.7675 | Number of books purchased: 8 Book Subtotal: $125.37 Tax: $6.8953500000000005 Shipping: $12.0 ------------------------ Order Total: $144.26535 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started