Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You operate a retail store with multiple cash registers. Define a class named CashRegister that has a member variable for a numeric register ID, a

You operate a retail store with multiple cash registers. Define a class named CashRegisterthat has a member variable for a numeric register ID, a member variable to hold total amount of sales made at the register, and a member variable to hold the total count of sales made at the register. Make a constructor that allows a user of the class to initialize the register ID and set the starting sales to $0. Also make a method named saleMade() that gets called each time a new sale is made at the register. This method should take in the dollar amount of the sale. When called, it should update the total amount of sales for THIS register. It should also update a member field that tracks the total count of sales made at THIS register.

Also, add a static variable that tracks the total number (count) of sales across all cash registers. Add a corresponding static method called getAllRegisterSalesCount() that returns the value in this variable. Each time saleMade() is called, this static count field should also be updated.

Finally. add a toString() method that will return a formatted string similar to the following:

  • Register# 1 has had 5 sales for a total of $5000.00. All registers together have made 25 sales.

Demonstrate a main() method to test your class with at least three registers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is a possible implementation of the CashRegister class class CashRegister private int registerID private double totalSales private int salesCount ... 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

Canadian Income Taxation Planning And Decision Making

Authors: Joan Kitunen, William Buckwold

17th Edition 2014-2015 Version

1259094332, 978-1259094330

More Books

Students also viewed these Programming questions

Question

Define success.

Answered: 1 week ago