Introduction
2part,partclientmethods,main,java
part23。client, Book classBookStore class。book,part1
,java
Requirement
CS1073 Assignment 3 Due: 8:30am October 4, 2016 in the Lab or any
time prior to 8:15am in the assignment bin.
Part 1. Write a program to implement a class called Client that contains the values: name,discount and cumulative
purchase amount. Supply an appropriate constructor and methods as described below:
• getName: returns the clients name
• addPurchase: accepts the current purchase amount as a parameter and adds it to the cumulative purchase
amount
• getPurchase: returns the cumulative purchase amount
• setDiscount: sets the client’s discount to a specified percentage
• getDiscount: returns the client’s discount
• resetClient: resets the discount percentage and the cumulative purchase amount of the client to zero
• The constructor: accepts one parameter (name) and sets the discount and cumulative amount to zero.
Write a main method in a driver class called TestClient to test the Client class. It should have the following functionality:
• Prompt the user for the name of the client and create the client (set the client’s discount and cumulative
purchase amount to zero).
• Prompt the user for a discount percentage for the client and update the client’s discount. Read the discount
percentage as an integer.
• The client makes a purchase. Prompt the user for the total amount of the current purchase before her/his
discount. Apply the client’s discount to the purchase amount. Remember that the client’s discount has been
stored as an integer, so to use it as a percentage you need to divide it by 100.00.
• Print the total amount to be paid by the client after her/his discount.
• Update the cumulative purchase amount of the client by adding the purchase amount after applying the
discount.
• The client gets a new discount for being a good client. Prompt the user for the new discount, and update it in
the client’s information.
• The client makes another purchase. Prompt the user for the total amount of the current purchase before
discount. Apply the client’s discount and print the total to be paid after the discount.
• Update the client’s cumulative purchase amount by adding the total payment after discount,
• Print the client’s information (name, discount, cumulative purchase).
• The store is starting a new selling season, the Christmas season. For this season reset the percentage discount
and cumulative purchase amount to zero. Print the client’s information (name, discount, cumulative purchase).
• Test your program for a client named Monique Levesque. She initially gets a 5% discount. In her first purchase,
she spends $245.99 before any discount. Her new discount for being a good client is 25%. She makes another
purchase of $60.00 before any discount.
Print all amounts rounded to two decimal places.
Part 2 In this part of the assignment you are going to use three classes. You are going to reuse the Client class that you
implemented above, and implement two new classes: a Book class and a BookStore class. The BookStore class is the
driver class for the Client and Book classes.
For the implementation of the Book class use the following guidelines. A book has a title, a price, and a discount. There
are four methods (getTitle. getPrice. setPrice. getDiscount) as well as two constructors as described below:
• getTitle: returns the title of the book.
• getPrice: returns the current price of the book.
• setPrice: changes the price to a specified amount.
• getDiscount: returns the current discount for the book.
First constructor: accepts two parameters (title and price) and sets the title and price while setting the discount
percentage to 0% (i.e. this book has no discount).
Second constructor: accepts three parameters (title. price and the discount percentage) and sets them all accordingly.
Write the BookStore class that uses the Client and Book classes. The main method of the BookStore class should have
the following functionality:
• Prompt the user for the first book (Title: HTML for the World Wide Web, Price: 24.95, Percentage Discount: 5%)
and create the corresponding book object.
• Read the discount percentage as an integer.
• Prompt the user for the second book (Title: Operating Systems. Price: 69.95). Do not prompt for the percentage
discount; let the class initialize it for you. Create the corresponding book object.
• Change the price of the HTML book to $30.00.
• Now create a client: Andrea Smith.
• Set Andrea’s percentage discount to 15%.
• Andrea buys the two books mentioned above. Print an invoice for Andrea. Obtain the cost of each book after
applying the individual book discount. Then. apply the client’s discount to the total cost of the books. Remember
that the discount values are integers and you have to divide them by 100.00 when you need to use them as a
percentage. The format of the invoice should be as follows
Andrea Smith
$ 28.50 HTML for the World Wide Web
$ 69.95 Operating Systems
————–
$ 98.45 subtotal
$ 14.77 Client’s Discount
————
$ 83.68 Total
• Update Andrea’s client information with the cumulative purchase amount.
• Print Andrea’s information (name, discount, cumulative purchase).
• Print all amounts rounded to two decimal places.
Summary:
You will have 2 class files: Client Book
You will have 2 driver files: TestClient Bookstore