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 float which

ID: 3633382 • Letter: D

Question

Define a class named Payment that contains a member variable of type float which stores the amount of the payment and appropriate accessor and mutator functions. Also create a member function named payment Details that outputs an English sentence describing the amount of the payment. Next define a class named Cash Payment that is derived from Payment. This class should redefine the payment Details function 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 payment Details function to include all credit card information in the printout. Create a main function that creates at least two Cash Payment and two CreditCardPayment objects with different values and calls to payment Details for each.

Explanation / Answer

Dear,

Here is the code
//Header file section
#include < iostream >
#include < string >
using namespace std;
class Payment
{
private: double amount;
public: Payment()
{
amount = 0;
}
Payment(double amount)
{
amount = amount;
}
void setPayment(double amount)
{
amount = amount;
}
double getPayment()
{
return amount;
}
void paymentDetails()
{
cout<<"The payment amount is "<< amount< }
};
class CashPayment : public Payment
{
public: CashPayment(): Payment()
{

}
CashPayment(double amt): Payment(amt)
{

}
void paymentDetails(){
cout<<"The cash payment amount is "<< getPayment()< }
};


class CreditCardPayment : public Payment
{
private: string name;
string expiration;
string creditcard;
public: CreditCardPayment(): Payment()
{

name = "";
expiration = "";
creditcard = "";
}
CreditCardPayment(double amt, string name, string expiration, string creditcard): Payment(amt)
{

name = name;
expiration = expiration;
creditcard = creditcard;
}
void paymentDetails()
{
cout<<"The credit card payment amount is "<< getPayment()< cout<<"The name on the card is: " << name< cout<<"The expiration date is: "< cout<<"The credit card number is: "< }
};

void main()
{
CashPayment cs1(500),cs2(2000.50);
//Function calls to display
cs1.paymentDetails();
cs2.paymentDetails();
//Credit object instantiation
     CreditCardPayment cd1(100,"Reena","11/6/1987","01123554");
cd1.paymentDetails();
system("pause");

}

Hope this will help you

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