Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

1. Using object oriented programming approach, write a 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) Write a menu-driven client program that can simulate the sale at a retail store.

o 1 Purchase

Create a 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

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

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

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

List and explain the four steps followed in the accounting process.

Answered: 1 week ago