Question: IMPORTANT: You only need to write the function definitions for the public member functions the rest of the code that is the class definition and
IMPORTANT: You only need to write the function definitions for the public member functions the rest of the code that is the class definition and the main driver program are given below.
Problem Description:
Define a class called Credit Card with the following data and member functions:
Private data:
string lastname
string firstname
int account_no
double balance
double credit_limit
int type - (1 = personal 2 = business)
Public member functions:
Constructor where you supply all the data fields
Set for each data field
Get for each data field
Function which adds to the balance when something is charged
Function which decrements the balance when a payment or credit is made
Function which determines if a charge can be made based on current balance and credit limit
Function which determines the cost of an item when given the cost of the item taking into account there is a 15% discount if the account is a business account and a 5% discount if a personal account
Function which determines the new end of month balance based on the current balance, an interest rate of 1.5 % monthly for unpaid balances and the amount paid that month by the person responsible for the account.
Print function which prints out the data fields for an object of this class
Please write the class definition and the member function definitions based on the above information
In your main program:
1. Declare one object Business with the detailed constructor that is call the constructor with the following values:
"Canaday","Kenny",5438,6000.00,1030.50.00,2
2. Declare another object Person with the default construtor and the use the set functions to set the following values in the private data fields.
"Leigh","Wanda",3215,2500.00 1681.70,1
3. Print out the data values of each of these objects using Get (not the print function)
4. Business charges 82.71 on the Business account
5. Print out Business data
6. Person returns a dress for a 31.58 credit
7. Print out Person data
8. Determine if Person can make a charge of 900.00 and if so then do it otherwise print cannot do it.
9. Print out Person data
10. Determine if Business can make a charge of 3000 and if so do it otherwise print cannot do it.
11. Print out Business data
12. Just figure out cost of items depending if a business or person - but no purchases are made so balances stay the same
Person wants to find price of something that cost 15.00
Business want to find price of something that costs 1000.00
13. Determine the new monthly balance for the Person account if Person makes a 300.00 payment
14. Print out Person data
15. Determine the new monthly balance for the Business account if Business makes a 2000.00 payment
16. Print out Business data
The following is the code for the above description.
IMPORTANT: YOU JUST NEED TO FILL IN THE PUBLIC MEMBER FUNCTION DEFINITIONS
Please use the code below: - JUST FILL IN the PUBLIC FUNCTION DEFINITIONS the class definition and main driver program are already there.
*/
#include
#include
#include
using namespace std;
class Credit_Card
{
public:
Credit_Card(string ln ="Noname", string fn="Noname", int acctno=0, double limit = 0.00, double current_balance=0.00, int type_acct = 1);
/* Set functions for each data member */
void SetLastName(string ln);
void SetFirstName(string fn);
void SetAccountNo(int acctno);
void SetCreditLimit(int limit);
void SetBalance(double start_balance);
void SetType(int type_acct);
/* Get functions for each data member */
string GetLastName() const;
string GetFirstName() const;
int GetAccountNo() const;
double GetCreditLimit() const;
double GetBalance() const;
int GetType() const;
/* other functions */
// function which adds to the balance when something is charged
void charge(double charge_amt);
//Function which decrements the balance when a payment is made or item// returned for credit
void credit(double credit_amt);
// Function which determines if a charge can be made based on
// current balance and credit limit
int OK_charge(double charge_amt) const;
// Function which determines the cost of an
// item when given the cost of the item taking into account there is
// a 15% discount if the account is a
// business account a 5% discount if a personal account
double cost_item(double cost) const;
// Function which determines the new end of month balance based on the
// current balance, an interest rate of 1.5 % monthly for unpaid balances
// and the payment made that month by the person responsible for the account.
void New_Balance(double payment_made);
//Print function which prints out the data fields for an object of this class
void Print() const;
private:
string lastname;
string firstname;
int account_no;
double credit_limit;
double balance;
int type; /* 1 is personal while 2 is business */
}; /* end of class definition */
/* PUBLIC MEMBER FUNCTION DEFINITIONS YOU MUST WRITE */
/*PLEASE ADD PUBLIC MEMBER FUNCTION DEFINITIONS HERE */
int
main()
{
cout<<"Created two Credit_Card Accounts: "< Credit_Card Business("Canaday", "Kenny", 5438,6000.00,1030.50,2); Credit_Card Person; Person.SetLastName("Leigh"); Person.SetFirstName("Wanda"); Person.SetAccountNo(3215); Person.SetCreditLimit(2500.00); Person.SetBalance(1681.70); Person.SetType(1); cout<<"Credit_Card Information for Account No. "< cout<<"Last Name:"< cout<<"First Name: "< cout<<"Credit Limit: $"< cout<<"Current Balance: $"< cout<<"Type of account: "; if(Business.GetType() == 1) { cout<<"Personal"; } else { cout<<"Business"; } cout< cout<<"Credit_Card Information for Account No. "< cout<<"Last Name:"< cout<<"First Name: "< cout<<"Credit Limit: $"< cout<<"Current Balance: $"< cout<<"Type of account: "; if(Person.GetType() == 1) { cout<<"Personal"; } else { cout<<"Business";} cout< cout<<"Canaday charged $82.71."< Business.charge(82.71); Business.Print(); cout<<"Leigh returned a dress that cost $31.58 for a credit to her account."< Person.credit(31.58); Person.Print(); cout<<"Leigh wants to charge $900.00 to her account."< if(Person.OK_charge(900)) { Person.charge(900); cout<<"The $900 charge went through for Leigh so her new account information is: "< Person.Print(); } else { cout<<"Leigh will exceed her credit limit of "< } if(Business.OK_charge(3000)) { Business.charge(3000); cout<<"The $3000 charge went through for Canaday so his new account information is: "< Business.Print(); } else { cout<<"Canaday will exceed his credit limit of "< } cout<<"Just checking prices to see if cost_item function works "< cout<<"but not actually purchasing items so the balance is not changed:"< cout<<"cost of item that cost $15.00 will cost Leigh - a person so a 5% discount - $"< cout<<"cost of item that cost $1000.00 will cost Canaday - a business so a discount of 15% - $"< cout<<"New monthly balance for Leigh after making a $300.00 payment is $"; Person.New_Balance(300); cout< cout< cout<<"New monthly balance for Canaday after make a $2000.00 payment is $"; Business.New_Balance(2000); cout< system("Pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
