Question: 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

1 Expert Approved Answer
Step: 1 Unlock

Here is a possible implementation of the CashRegister class class CashRegister private int registerID private double totalSales private int salesCount ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!