$24
Introduction
A retail store has a preferred customer plan where customers can earn discounts on all their purchases. The amount of a customer’s discount is determined by the amount of the customer’s cumulative purchases in the store as follows:
When a preferred customer spends $500, he or she gets a 5 percent discount on all future
purchases.
When a preferred customer spends $1,000, he or she gets a 6 percent discount on all future
purchases.
When a preferred customer spends $1,500, he or she gets a 7 percent discount on all future
purchases.
When a preferred customer spends $2,000 or more, he or she gets a 10 percent dis- count on all future purchases.
Problem Statement
Develop a PreferredCustomer.java class and write a test-driver program (PreferredCustomerDriver.java) to test the class. Your implementation must meet the following design requirements.
Design Requirements
Begin by designing a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor
methods for the class’s fields.
Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a Boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator and accessor
methods for the class’s fields.
Then, design the PreferredCustomer class which extends the Customer class. The PreferredCustomer class should have fields for the amount of the customer’s purchases and the customer’s discount level. Write one or more constructors and the appropriate mutator and
accessor methods for the class’s fields.
Finally, write a test-driver program, PreferredCustomerDriver.java, to demonstrate the class. The test-driver program obtains its input from a data file (customers.txt). Your program should use this file name and should not ask for the name of an input file.
Program Input
The test-driver program obtains its data from a data file (customers.txt) with data organized as follows. Each line in the input file represents a preferred customer. Therefore, each line consists of the following data values separated by semicolons: customer name, customer address, customer phone number, customer id, a Boolean value (true/false), and a customer’s purchases amount. Here are the first few lines in a sample input file:
Nadia Ajwa; 860 Stone Creek Blvd, Ashland, OH 44805; 419-555-1111; 111-AJ1234; true; 2000.99
Iyad Ajwa; 860 Stone Creek Blvd, Ashland, OH 44805; 419-207-9492; 111-AJ1235; false; 500.00
Julie James; 123 Main Street, Allentown, OH 44489; 567-555-1212; 147-A049; true; 1750.00
Program Output
The test-driver program displays the customer name as well as the customer’s discount level. In addition, the program should generate two lists for interested customers. The first list is a mailing list consisting of the customer address and phone number formatted in the usual format. The second list is a list of customers’ phone numbers. Below is a sample output based on the sample input data provided above:
Customer Name
Customer’s Discount Level
Customer’s Number
=============
======================
================
Nadia Ajwa
10%
111-AJ1234
Iyad Ajwa
5%
111-AJ1235
Julie James
7%
147-AO4936
Mailing List:
Nadia Ajwa
860 Stone Creek Blvd
Ashland, OH 44805
Julie James
123 Main Street
Allentown, OH 44489
Phone List:
Nadia Ajwa
419-555-1111
Julie James
567-555-1212
Program is done.
Bye!
Submission Instructions
When you are satisfied with your implementation, and after testing it thoroughly, submit the Person.java, Customer.java, PreferredCustomerDriver.java, and the PreferredCustomerDriver.java files on Blackboard.