Question: Java Assignment: You have opened a bookstore, and have decided to write your own point-of-sale system to sell books. You sell several items: Books ($5.00
Java Assignment:
You have opened a bookstore, and have decided to write your own point-of-sale system to sell books. You sell several items:
Books ($5.00 each)
Bookmarks ($1.00 each, or a pack of six for $5.00)
Paintings of Books ($100.00 each)
Customers can purchase any number of each item. However, if a customer purchases bookmarks, it will always give them packs if possible, thus allowing for a cheaper price. For example, if somebody buys 3 bookmarks, they will not buy a pack - it will cost them $3.00. However, if they buy 7, then they will automatically get one pack and one extra bookmark, for a total cost of $5.00 + $1.00 = $6.00 - not $7.00.
We will assume that you are operating the bookstore in Oakland, so you will need to add 7% additional tax (Pennsylvania and Allegheny County taxes) on all sales. For example, if somebody buys one book at $5.00, then the total cost should be $5.00 + $0.35 in tax, or $5.35.
All values should be rounded to the nearest cent.
Additionally, in order to attract business, you are running a promotion: every third customer will get 10% off their order (before tax). This will start with the third customer; the first customer will not get a discount, the second customer will not get a discount, but the third one, sixth one, ninth one, etc. will. For example, if the third customer buys a book, they would get $0.50 off (10% of $5.00), for a total of $4.50, and then tax would be added ($4.185, which would be rounded to $4.82).
If the customer does not get a discount, then along with the receipt, the message "You did not get a discount! Better luck next time!" If the customer does get a discount, display the discount amount and the message "You won a 10% discount!"
You will write a Java program that runs a point-of-sale service for your bookstore. The program should do the following:
Ask if another customer is waiting in line, and have the user enter an integer - 1 for yes and 2 for no.
If no customers are waiting in line, exit the program.
Show the customer a menu which has all items and their prices listed, as well as options to show the current order and check out. Customers should be able to modify their order (for example, if they accidentally enter that they want to purchase four books, then put one back, they should be able to modify that to three books).
Showing the current order should show how many of each item the customer is going to purchase.
Checking out will consist of showing a tabulated receipt with how many of each item was purchased. If an item was not purchased, it should not display (so there should be no "Books: 0 $0.00" lines. If the "Third Customer Discount" was applied, it should show that as a separate (before tax) line. It should include a subtotal (before tax), and then a total (after tax).
Finally, ask the user to pay for it. The system should accept a floating-point number from the user. If it is less than the cost of the customer's purchase, the system should print "Not enough money - please re-enter" and ask again. The system should continue to do this until a valid amount of money (the cost of the total or greater) is entered. Once a valid amount of money is entered, indicate the change given (for example, if the purchase is $96.50 and the customer gives $100.00, show that the change should be $3.50).
SAMPLE OUTPUT:
More customers in line? (1 = Yes, 2 = No) 1 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 1 Currently in cart: 0 books. How many do you want to buy? > 1 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 1 Currently in cart: 1 books. How many do you want to buy? > 5 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 4 Currently in cart: Books: 5 Bookmarks: 0 Paintings of books: 0 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 2 Currently in cart: 0 bookmarks. How many do you want to buy? > 15 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 3 Currently in cart: 0 paintings. How many do you want to buy? > 2 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 4 Currently in cart: Books: 5 Bookmarks: 15 Paintings of books: 2 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > -1 Please enter a valid option (1 through 5) > 17 Please enter a valid option (1 through 5) > 999 Please enter a valid option (1 through 5) > 5 -------------------------------------- You did not get a discount! Better luck next time! 5 Book(s): $25.00 2 Bookmark Pack(s): $10.00 3 Single Bookmark(s): $3.00 2 Painting(s): $200.00
Subtotal: $238.00 Tax: $16.66
Total: $254.66
--------------------------------------
Enter amount paid (no dollar sign) > 260.00
Your change is: $5.34 Thanks for shopping! More customers in line? (1 = Yes, 2 = No) 1 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 2 Currently in cart: 0 bookmarks. How many do you want to buy? > 3 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 4 Currently in cart: Books: 0 Bookmarks: 3 Paintings of books: 0 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 5 -------------------------------------- You did not get a discount! Better luck next time! 3 Single Bookmark(s): $3.00
Subtotal: $3.00 Tax: $0.21
Total: $3.21
--------------------------------------
Enter amount paid (no dollar sign) > 1.00 Not enough money, please re-enter. Enter amount paid (no dollar sign) > -20.35 Not enough money, please re-enter. Enter amount paid (no dollar sign) > 20
Your change is: $16.79 Thanks for shopping! More customers in line? (1 = Yes, 2 = No) 1 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 3 Currently in cart: 0 paintings. How many do you want to buy? > 2 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 1 Currently in cart: 0 books. How many do you want to buy? > -1 Enter a valid number of books - 0 or more 0 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 4 Currently in cart: Books: 0 Bookmarks: 0 Paintings of books: 2 1 - Buy Books - $5.00 each 2 - Buy Bookmarks - $1.00 each, $5.00 for a six-pack 3 - Buy Paintings of Books - $100.00 each 4 - See current order 5 - Checkout Please enter a valid option (1 through 5) > 5 -------------------------------------- You won a 10% discount! 2 Painting(s): $200.00 Discount! Saved: -$20.00
Subtotal: $180.00 Tax: $12.60
Total: $192.60
--------------------------------------
Enter amount paid (no dollar sign) > 200.00
Your change is: $7.40 Thanks for shopping! More customers in line? (1 = Yes, 2 = No) 2 No more customers! Closing!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
