Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Define a class with the name CreditCard and the following members: Data Members: a. name: name of account holder b. creditLimit: limit of credit

Instructions:

Define a class with the name CreditCard and the following members: Data Members: a. name: name of account holder b. creditLimit: limit of credit amount allowed c. creditBalance: balance charged on the account d. interestRate: annual interest rate on creditBalance. e. accountID: unique 3 digit account ID assigned to each CreditCard object. Use a static data member to generate this unique account ID for each CreditCard object created. f. count: A static data member to track the count of the number of CreditCard objects created. Member Functions g. void charge(double amount): function which applies charge on CreditCard. h. void payment(double amount): function which pays an amount towards the creditBalance. i. void calculateMonthlyInterest( ): function which calculates the monthly interest and adds interest to the creditBalance. j. void displayCreditInfo( ): function which displays the account holder name, accountID, chargeBalance, creditLimit, interestRate and count of the number of CreditCard objects created.

Define the derived classes PremiumCard and BusinessCard from class CreditCard with the following annual interest rates and credit card charge limits: const double DEFAULT_INTEREST_RATE_PREMIUM = 0.12; const double DEFAULT_INTEREST_RATE_BUSINESS = 0.10; const double PREMIUM_CHARGE_LIMIT = 2000.00; const double BUSINESS_CHARGE_LIMIT = 5000.00; If the chargeBalance of the PremiumCard or BusinessCard object exceeds the credit card limit then the following fees will be charged: const double DEFAULT_FEE_PREMIUM = 150.0; //PremiumCard Fee const double DEFAULT_FEE_BUSINESS = 50.0; //BusinessCard Fee

I am stuck on how to make the derived classes and how to design the file, the code for the first part should be close

CreditCard.cpp

#include #include #include "PremiumCard.h" #include "BusinessCard.h" using namespace std;

class CreditCard {

private:

string name; double creditlimit; double creditBalance; double interestRate; int accountID; static int count;

int BankAccount::count = 0; accountID(double balance, double rate) { creditBalance = balance; interestRate = rate; accountId = 101 + count; count++; } void charge(double amount)

{ if (amount > creditBalance) { cout << "Insufficient balance." << endl; return; } else { accountBalance -= amount; }

} void payment(double amount) { creditBalance += amount; } void calculateMonthlyInterest() { creditBalance* (interestRate / 100); } void displayCreditInfo() { cout << "account holder name: ", name, " accountID: ", accountID, " Charge balance: ", chargeBalance, " Credit limit: ", creditLimit, " Interest rate: ", interestRate, " Objects created:", count }

}

int main() { BusinessCard businessCard1(Happy Reading Bookstore LLC); BusinessCard businessCard2(Triangle Florist LLC); PremiumCard premiumCard1(Charlie Brown); PremiumCard premiumCard2(Lucy Van Pelt); businessCard1.charge(6000); businessCard2.charge(2500); premiumCard1.charge(2100); premiumCard2.charge(250); businessCard1.calculateMonthlyInterest(); businessCard2.calculateMonthlyInterest(); premiumCard1.calculateMonthlyInterest(); premiumCard2.calculateMonthlyInterest(); cout << "***********************************" << endl; businessCard1.displayCreditInfo(); businessCard2.displayCreditInfo(); premiumCard1.displayCreditInfo(); premiumCard2.displayCreditInfo(); cout << "***********************************" << endl << endl; businessCard1.payment(5000); businessCard2.payment(2500); premiumCard1.payment(2100); premiumCard2.payment(290); cout << "********After Payment ***************" << endl; businessCard1.displayCreditInfo(); businessCard2.displayCreditInfo(); premiumCard1.displayCreditInfo(); premiumCard2.displayCreditInfo(); cout << "***********************************" << endl << endl; system("pause"); return 0; }

PremiumCard.h

class PremiumCard::private CreditCard { const double DEFAULT_INTEREST_RATE_PREMIUM = 0.12;

}

BusinessCard.h

class BusinessCard:: private CreditCard { const double DEFAULT_INTEREST_RATE_BUSINESS = 0.10;

}

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

What are qualitative characteristics?

Answered: 1 week ago

Question

What does the approach of DM as practice focus on?

Answered: 1 week ago