Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1 Starting with a new Java application (project) named PRACTICE , add a CashRegister class that models a store cash register. Then, add to

Part 1

Starting with a new Java application (project) named PRACTICE, add a CashRegister class that models a store cash register.

Then, add to this class:

instance variable for the list of item prices (e.g., named items),

constructor that creates the list of item prices (initially empty): public CashRegister() { items = new ArrayList(); }

instance methods to:

add an item with a given price (argument),

get the purchase total,

get the number of items purchased,

clear the cash register for the next customer,

return (as a String) the list of item prices.

Part 2

Add a main class (e.g., named Main) with a main method to the CPS151_Lab5 project and add code to the main method that does the following:

Declare/create an object of type CashRegister.

Using method calls to the CashRegister object, add three items with prices $1.95, $0.95 and $2.50.

Using method calls to the CashRegister object, display (1) the number of items purchased (2) the list of prices, and (3) the total price of the entire purchase.

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions