Page 1 of 1

The goal of this lab is to write a java program that acts as a way to store payments, depending on whether a customer pa

Posted: Sun May 15, 2022 10:02 am
by answerhappygod
The goal of this lab is to write a java program that acts as a
way to store payments, depending on whether a customer pays with
cash or credit card.
1. Define a class called Payment that contains a private
variable of type double that stores the amount of the payment.
Include the appropriate getters and setters. Also, create a method
called paymentDetails that outputs a sentence to describe the
payment amount.
2. Define a class named CashPayment that extends the Payment
class. This class should redefine the paymentDetails method to
indicate that the payment is made in cash.
3. Define a class named CreditCardPayment that contains private
variables for the name on the card, the expiration date, and the
credit card number. Create appropriate getters and setters. Again,
redefine a paymentDetails method to include all credit card
information in the print out.
4. In your MainClass, create two CashPayment objects and two
CreditCardPayment objects with different values and call
paymentDetails for both. A sample run is below:
You paid $500. 0 I n c an s h .
You p a i d $800 . 0 i n c a s h .
You p a i d $650 . 0 t o be c h a r g e d t o Joey on c a r d 8
7 2 4 9 1 2 4 7 2 w i t h e x p i r a t i o n 1 2 / 0 9 .
You p a i d $100 . 0 t o be c h a r g e d t o Kara on c a r d 9
8 3 4 2 3 9 4 2 3 w i t h e x p i r a t i o n 5 / 2 3 .