View the step-by-step solution to:

Using object oriented programming approach, Cash Register program. - Define a class Product (Product.java) o Three private data members:

1.     Using object oriented programming approach, Cash Register program.

 

-       Define a class Product (Product.java)

o  Three private data members: product name, unit price, units to purchase

o  One static constant: sales tax rate = 0.0675

o  Two overloaded constructors

§ Ensure that both unit price and units to purchase are valid ( > = 0 )

o  Get and set methods for each private data member

§ Ensure that both unit price and units to purchase are valid ( > = 0 ) in setters

o  A method to calculate and return the purchase price before tax

§ price before tax = unit price * units to purchase

o  A method to calculate and return the purchase price after tax

§ price after tax = price before tax * ( 1 + sales tax rate )

o  toString() method

 

-       (CashRegister.java) menu-driven client program that can simulate the sale at a retail store.

o  1 - Purchase

Product object based on the user input and calculate its purchase prices before and after tax

o  2 - Check Out

Print the receipt (the receipt should include all the purchases)

 

-       Incorporate "this" reference in the Product class

 

Sample run

**************Cash Register****************************

1 --- Purchase

2 --- Check Out (Print Receipt)

0 --- Exit

*******************************************************

Select an option: 1

Enter product name: Chair

Enter product unit price: 235.99

Enter units to purchase: 4

Product Name: Chair

Unit Price: $235.99

Unit Purchase: 4

Purchase price before tax: $943.96

Sales Tax Rate: 6.75%

Purchase price after tax: $1007.68

Select option 1 to add more purchase.

Select option 2 to print the receipt.

**************Cash Register****************************

1 --- Purchase

2 --- Check Out (Print Receipt)

0 --- Exit

*******************************************************

Select an option: 1

Enter product name: Table

Enter product unit price: 1239.75

Enter units to purchase: 1

Product Name: Table

Unit Price: $1239.75

Unit Purchase: 1

Purchase price before tax: $1239.75

Sales Tax Rate: 6.75%

Purchase price after tax: $1323.43

Select option 1 to add more purchase.

Select option 2 to print the receipt.

**************Cash Register****************************

1 --- Purchase

2 --- Check Out (Print Receipt)

0 --- Exit

*******************************************************

Select an option: 2

--------Receipt -------------------------


Product Name: Chair

Unit Price: $235.99

Unit Purchase: 4

Product Name: Table

Unit Price: $1239.75

Unit Purchase: 1

Total Purchase price before tax: $2183.71

Sales Tax Rate: 6.75%

Total Purchase price after tax: $2331.11

------------------------------------------

Top Answer

Product.java: //product class class Product {     //three private member     private String name;     private double... View the full answer

output.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online