Exercise 2 Design a class named Customer with field holding for customer's name, address, and telephone number. Customer's name and address can only be accessed by Customer class. Telephone number can...


Exercise 2<br>Design a class named Customer with field holding for customer's name, address, and telephone<br>number. Customer's name and address can only be accessed by Customer class. Telephone<br>number can only be accessed by its subclass. Write two overloading constructors and the<br>appropriate setter and getter methods for the class's fields.<br>A retail store has a preferred customer plan where customers can earn discounts on all their<br>purchases. The amount of a customer's discount is determined by the amount of the<br>customer's cumulative purchases in the store as follows:<br>• When a preferred customer spends RM500, he or she gets 5 percent discount on all<br>future purchases<br>• When a preferred customer spends RM1,000, he or she gets 6 percent discount on<br>all future purchases<br>• When a preferred customer spends RM1,500, he or she gets 7 percent discount on<br>all future purchases<br>When a preferred customer spends RM2,000 or more, he or she gets 10 percent<br>discount on all future purchases<br>Design a class named PreferredCustomer, which extends the Customer class. The<br>PreferredCustomer class should have fields for the amount of the customer's<br>purchases and the customer's discount level.<br>Write one or more constructors and the appropriate setter and getter methods for the class's<br>field. Demonstrate the class in a simple program that asks a user to enter his or her<br>cumulative purchases and display all the fields. Output example:<br>How much is your cumulative purchases? RM1700.30<br>Customer's name: Hadif<br>Address: Durian Tunggal<br>Phone: 0115544331<br>Cunulative purchases: RM1,700.30<br>Discount level: ?.00 %<br>

Extracted text: Exercise 2 Design a class named Customer with field holding for customer's name, address, and telephone number. Customer's name and address can only be accessed by Customer class. Telephone number can only be accessed by its subclass. Write two overloading constructors and the appropriate setter and getter methods for the class's fields. 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 RM500, he or she gets 5 percent discount on all future purchases • When a preferred customer spends RM1,000, he or she gets 6 percent discount on all future purchases • When a preferred customer spends RM1,500, he or she gets 7 percent discount on all future purchases When a preferred customer spends RM2,000 or more, he or she gets 10 percent discount on all future purchases Design a class named PreferredCustomer, 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 setter and getter methods for the class's field. Demonstrate the class in a simple program that asks a user to enter his or her cumulative purchases and display all the fields. Output example: How much is your cumulative purchases? RM1700.30 Customer's name: Hadif Address: Durian Tunggal Phone: 0115544331 Cunulative purchases: RM1,700.30 Discount level: ?.00 %
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here