Question: Payment Problem (Java language): Define a class called Payment which contains an instance variable of type double that stores the amount of a payment. Include

Payment Problem (Java language):

Define a class called Payment which contains an instance variable of type double that stores the amount of a payment. Include appropriate getter/setter methods in your class. Include a method named paymentDetails which outputs an English sentence describing the payment.

Next define a class named CashPayment which is derived from Payment. The class should redefine the paymentDetails method to indicate that the payment is cash. Include necessary constructors for this class.

In addition to this, define a third class called CreditCardPayment that is derived from Payment. This class should contain instance variables for the: Cardholders Name Expiration Date Credit Card Number

Lastly modify the paymentDetails method on this class to include all credit card information in the printout. Include a main method in your submission (either in one of the three classes or in a separate class) which demonstrates two instances of CashPayment and at least two instances of CreditCardPayment and the different values of paymentDetails for each.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!