(Solved) : Using C Given Files Construct Code Code Given Maincpp Include Cashdebitcardhpp Include Int Q42720580 . . .

Using C++, and the given files, construct thecode.

CODE GIVEN FOR main.cpp

#include “cash_debit_card.hpp”
#include

int main() {
std::string name;
int choice;
double amount_due;
double balance;
std::cout << “Enter the total price: $”;
std::cin >> amount_due;
std::cin.ignore();
std::cout << “Enter your name: “;
std::getline(std::cin, name);
std::cout << “Choose the card you will be payingwith:n”;
std::cout << “1 – Cash Cardn”;
std::cout << “2 – Debit Cardn”;
std::cout << “Choice: “;
std::cin >> choice;
std::cout << “Enter the balance on your card: $”;
std::cin >> balance;
if (choice == 1) {
// Create an instance of the `CashCard` object using thenon-default
// constructor and passing in the values entered by the user

// Charge the card by calling the respective function
  
std::cout << “The amount left on your card is $” <<std::setprecision(2)
<< std::fixed << card.balance() << “n”;
} else if (choice == 2) {
// Create an instance of the `DebitCard` object using thenon-default
// constructor and passing in the values entered by the user

// Charge the card by calling the respective function
  
std::cout << “The amount left on your card is $” <<std::setprecision(2)
<< std::fixed << card.balance() << “n”;
} else {
std::cout << “Error – Invalid Option, please tryagain.n”;
}
return 0;
}

1 minute agc cash_debit_card.cpp Initial commit 1 minute agc Initial commit cash_debit_card.hpp 1 minute agc Initial commit c

Debit Card Class Create a DebitCard class that inherits from CashCard . This type of card has an infinite balance, but overdr

1 minute agc cash_debit_card.cpp Initial commit 1 minute agc Initial commit cash_debit_card.hpp 1 minute agc Initial commit config.mk 1 minute agc Initial commit main.cpp README.md Cash/Debit Card In this program, you will be implementing classes using inheritance. Cash Card Class Create a Cash Ca rd class. This type of card has a finite balance, and overdrawing from the card will cause the transaction to fail. This class will have the following: Data members 1. balance_ which is a double that stores the amount of money on the card. 2. name_ which is a std::string that will be the owner of the card Default Constructor Create a default constructor that will set name_ to “Alex Amarnani” and balance_ to 100.00 . Non-Default Constructor Create a non-default constructor that receives 2 parameters, a double for the balance and a std::string for the name respectively. Accessors and Mutators Create accessors and mutators for name_ and balance_ . Member functions charge_balance (Protected) Create a protected member function called charge_balance that will pass in a double for the amount of money being charged to the card. This function should subtract the amount of money passed in from the balance. charge Create a public member function for CashCard called charge that will pass in a double for the amount of money being charged to the card. This function should check whether the amount is less than or equal to the current balance. If there is enough balance, it should call the charge_balance function and pass in the amount to update the balance. Otherwise, it should print on screen “Insufficient funds” . Debit Card Class Create a DebitCard class that inherits from CashCard . This type of card has an infinite balance, but overdrawing from the card will result in a $30.00 overdraft fee This class has no additional data members. Default Constructor Create a default constructor that calls its non-default constructor and pass in the values 100.00 and “Sidney Lee” . Non-Default Constructor Create a non-default constructor that receives 2 parameters, a double for the balance and a std: :string for a name respectively. Call CashCard ‘s non-default constructor and pass the 2 parameters. charge Create a the charge member function that will pass in a double for the amount of money being charged to the card. This member function will override the base class’ implementation The function should check whether the amount is greater than the current balance. If it is greater than the balance, it should call the charge_balance function and pass in a value of 30.00 then, display on the screen “0ve rd raft Fee of $30.00 Incurred” . It should call the charge_balance function again and pass in the actual amount the user spends and updates the balance accordingly Other instructions Complete the main function as described. Place your classes in cash_debit_card.hpp . Member functions that take more than five lines or use complex constructs should have their function prototype in cash_debit_card.hpp and implementation in cash_debit_card.cpp Sample Output Normal Cash Card behavior Enter the total price: $35.00 Enter your name: Alex Amarnani Choose the card you will be paying with: 1 – Cash Card 2 Debit Card Choice: 1 Enter the balance on your card: $40.00 The amount left on your card is $5.00 Show transcribed image text 1 minute agc cash_debit_card.cpp Initial commit 1 minute agc Initial commit cash_debit_card.hpp 1 minute agc Initial commit config.mk 1 minute agc Initial commit main.cpp README.md Cash/Debit Card In this program, you will be implementing classes using inheritance. Cash Card Class Create a Cash Ca rd class. This type of card has a finite balance, and overdrawing from the card will cause the transaction to fail. This class will have the following: Data members 1. balance_ which is a double that stores the amount of money on the card. 2. name_ which is a std::string that will be the owner of the card Default Constructor Create a default constructor that will set name_ to “Alex Amarnani” and balance_ to 100.00 . Non-Default Constructor Create a non-default constructor that receives 2 parameters, a double for the balance and a std::string for the name respectively. Accessors and Mutators Create accessors and mutators for name_ and balance_ . Member functions charge_balance (Protected) Create a protected member function called charge_balance that will pass in a double for the amount of money being charged to the card. This function should subtract the amount of money passed in from the balance. charge Create a public member function for CashCard called charge that will pass in a double for the amount of money being charged to the card. This function should check whether the amount is less than or equal to the current balance. If there is enough balance, it should call the charge_balance function and pass in the amount to update the balance. Otherwise, it should print on screen “Insufficient funds” .
Debit Card Class Create a DebitCard class that inherits from CashCard . This type of card has an infinite balance, but overdrawing from the card will result in a $30.00 overdraft fee This class has no additional data members. Default Constructor Create a default constructor that calls its non-default constructor and pass in the values 100.00 and “Sidney Lee” . Non-Default Constructor Create a non-default constructor that receives 2 parameters, a double for the balance and a std: :string for a name respectively. Call CashCard ‘s non-default constructor and pass the 2 parameters. charge Create a the charge member function that will pass in a double for the amount of money being charged to the card. This member function will override the base class’ implementation The function should check whether the amount is greater than the current balance. If it is greater than the balance, it should call the charge_balance function and pass in a value of 30.00 then, display on the screen “0ve rd raft Fee of $30.00 Incurred” . It should call the charge_balance function again and pass in the actual amount the user spends and updates the balance accordingly Other instructions Complete the main function as described. Place your classes in cash_debit_card.hpp . Member functions that take more than five lines or use complex constructs should have their function prototype in cash_debit_card.hpp and implementation in cash_debit_card.cpp Sample Output Normal Cash Card behavior Enter the total price: $35.00 Enter your name: Alex Amarnani Choose the card you will be paying with: 1 – Cash Card 2 Debit Card Choice: 1 Enter the balance on your card: $40.00 The amount left on your card is $5.00

Expert Answer


Answer to Using C++, and the given files, construct the code. CODE GIVEN FOR main.cpp #include “cash_debit_card.hpp” #include int …

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?