Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a class named Payment that contains an instance variable paymentAmount (non-static member variable) of type double that stores the amount of the payment and

Define a class named Payment that contains an instance variable "paymentAmount" (non-static member variable) of type double that stores the amount of the payment and appropriate accessor (getPaymentAmount() ) and mutator methods. Also create a method named paymentDetails that outputs an English sentence to describe the amount of the payment. Override toString() method with contents of payment amount and details.

Next, define a class named CashPayment that is derived from Payment. This class have an additional instance variable of type String (a non-static member variable) that specifies a type of currency, such as "dollar", "euro", "peso", "yen", etc. This class should redefine the paymentDetails method to indicate that the payment is in cash, and type of currency. Include appropriate constructor(s). Override toString() method with contents of payment details.

Define a class named CreditCardPayment that is derived from Payment. This class should contain instance variables (member variables) for the name on the card, expiration date, and credit card number. Include appropriate constructor(s). Finally, redefine thepaymentDetails method to include all credit card information in the printout.

Override toString() method with contents of cash payment details.

Create a PayTester class with main method that creates at least two CashPayment and two CreditCardPayment objects with different values. Set payment for two objects by using setPaymentAmount() (mutator) method. Call toString() methods from each object to get the details of payments.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions