Question
Design and implement a CashRegister class that scans the product prices, counts the number of items and shows the total purchase. Hints: Scanning a product
Design and implement a CashRegister class that scans the product prices, counts the number of items and shows the total purchase.
Hints:
Scanning a product price is to take the price and add it to the total purchase;
You do not need to consider rounding and formatting purchase values to dollars and cents in this exercise.
First, identify class fields (object state) that are required and method (object behaviours) that are needed on the fields (accessor or mutator the state). Create a class diagram to describe your class design in the startup code CashRegister.java
Design and implement a class that scans the product prices, counts the number of items and shows the total purchase.
using the following format.
============================== CashRegister ------------------------------ (fields here)
------------------------------ (methods here)
==============================
Now, complete the main program,
to scan products and display the number of items and total purchase as indicated in
the program and follows. The
CheckOut
Product
, using your
CheckOut.java CashRegister
program will use your
1. CreateaCashRegisterobject; 2. scan3products:Milk($2.99),Apple($5.49)andBread($1.75); 3. displaythenumberofitemspurchased; 4. displaythetotalpurchase; 5. scanonemoreproduct:Apple; 6. displaythenumberofitemspurchased; 7. displaythetotalpurchase; 8. createanotherCashRegisterobject; 9. scan2products:MilkandBread; 10.display the number of items purchased; 11.display the total purchase.
Compile and run CheckOut program. You should see the following output:
***** At Register 1 ***** You have purchased 3 items Total: $10.23 You have purchased 4 items Total: $15.72
***** At Register 2 ***** You have purchased 2 items Total: $4.74
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