Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Define a class named Payment that contains a member variable of type double that

ID: 3553523 • Letter: D

Question


Define a class named Payment that contains a member variable of type double that stores

the amount of the payment and appropriate accessor and mutator methods. Also create a

method named paymentDetails that outputs an English sentence to describe the amount of

the payment. Next, define a class named CashPayment that is derived from Payment. This

class should redefine the paymentDetails method to indicate that the payment is in cash.

Include appropriate constructor(s). Define a class named CreditCardPayment that is derived

from Payment. This class should contain member variables for the name on the card,

expiration date, and credit card number. Include appropriate constructor(s). Finally, redefine

the paymentDetails method to include all credit card information in the printout. Create a

main method that creates at least two CashPayment and two CreditCardPayment objects

with different values and calls paymentDetails for each.

ANSWER HINT******

/**

* This program introduces inheritance through a problem of

* creating two types of Payments, Cash and Credit. The

* paymentDetails method outputs in English a sentence that describes

* the payment.

*/

/**

* Base class that holds payment amount provides a method for returning

* a description of the payment.

*/

public class Payment

{

//Payment amount

private double amount;

//Constructor to initialize amount to 0

public Payment()

{

amount = 0.0;

}

/**

* Constructor to initialize payment amount

*/

public Payment(double paymentAmount)

{


/**Must be your own original code. No copy and paste from internet. Easy to locate copied code. Also, must have java comments, state below (1). Points rewarded once ALL requirements are met. Thanks. **/


1. Comments within your code. Please look up how to do JavaDoc style comments if you don't know how. Using Eclipse IDE, you can have Eclipse create the comments sections for you automatically. This is critical in going forth in your future classes. You should have method documentations as well as inline documentations. Example:

Explanation / Answer

Project -> Generate Javadoc


In the "Javadoc command" field - browse to find javadoc.exe On the computers in the Clapp CS lab that is C:JBuilderXjdk1.4injavadoc.exe On other computers it would be injavadoc.exe


Check the box next to the project/package/file for which you are creating the javadoc


In the "Destination" field browse to find the desired destination (for example, the root directory of the current project).


Leave everything else as it is.


Click "Finish"


Javadoc should be in the destination folder. Open "index.html"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote