1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
class Credit_Card
{
public:
Credit_Card(string ln, string fn, int acctno, double limit, double current_balance, int type_acct);
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);
void charge(double charge_amt);
void credit(double credit_amt);
void New_Balance(double payment_made);
void Print() const;
string GetLastName() const;
string GetFirstName() const;
int GetAccountNo() const;
int GetType() const;
int OK_charge(double charge_amt) const;
double cost_item(double cost) const;
double GetCreditLimit() const;
double GetBalance() const;
private:
string LastName;
string FirstName;
int account_no;
double credit_limit;
double balance;
int type;
};
void Credit_Card::SetLastName(string ln) {
LastName=ln;
}
void Credit_Card::SetFirstName(string fn) {
FirstName = fn;
}
void Credit_Card::SetAccountNo(int acctno) {
account_no = acctno;
}
void Credit_Card::SetCreditLimit(int limit) {
credit_limit = limit;
}
void Credit_Card::SetBalance(double start_balance) {
balance = start_balance;
}
void Credit_Card::SetType(int type_acct) {
type = type_acct;
}
string Credit_Card::GetLastName() const {return LastName;}
string Credit_Card::GetFirstName() const {return FirstName;}
int Credit_Card::GetType() const {return type;}
int Credit_Card::GetAccountNo() const {return account_no;}
double Credit_Card::GetCreditLimit() const {return credit_limit;}
double Credit_Card::GetBalance() const {return balance;}
int main()
{
cout<<"Created two Credit_Card Accounts: "<<endl;
Credit_Card Business("Canaday", "Kenny", 5438,6000.00,1030.50,2);
Credit_Card Person("Leigh", "Wanda",3215,2500.00,1681.70,1);
cout<<"Credit_Card Information for Account No. "<<Business.GetAccountNo()<<":"<<endl;
cout<<"Last Name:"<<Business.GetLastName()<<endl;
cout<<"First Name: "<<Business.GetFirstName()<<endl;
cout<<"Credit Limit: $"<<Business.GetCreditLimit()<<endl;
cout<<"Current Balance: $"<<Business.GetBalance()<<endl;
cout<<"Type of account: ";
if(Business.GetType() == 1)
{
cout<<"Personal";
}
else
{
cout<<"Business";
}
cout<<endl;
cout<<"Credit_Card Information for Account No. "<<Person.GetAccountNo()<<":"<<endl;
cout<<"Last Name:"<<Person.GetLastName()<<endl;
cout<<"First Name: "<<Person.GetFirstName()<<endl;
cout<<"Credit Limit: $"<<Person.GetCreditLimit()<<endl;
cout<<"Current Balance: $"<<Person.GetBalance()<<endl;
cout<<"Type of account: ";
if(Person.GetType() == 1)
{
cout<<"Personal";
}
else
{
cout<<"Business";}
cout<<endl;
cout<<"Canaday charged $82.71."<<endl;
Business.charge(82.71);
Business.Print();
cout<<"Leigh returned a dress that cost $31.58 for a credit to her account."<<endl;
Person.credit(31.58);
Person.Print();
cout<<"Leigh wants to charge $900.00 to her account."<<endl;
if(Person.OK_charge(900))
{
Person.charge(900);
cout<<"The $900 charge went through for Leigh so her new account information is: "<<endl;
Person.Print();
}
else
{
cout<<"Leigh will exceed her credit limit of "<<Person.GetCreditLimit()<<endl<<"with a charge of $900 so she cannot make a charge of 900 dollars."<<endl;
}
if(Business.OK_charge(3000))
{
Business.charge(3000);
cout<<"The $3000 charge went through for Canaday so his new account information is: "<<endl;
Business.Print();
}
else
{
cout<<"Canaday will exceed his credit limit of "<<Business.GetCreditLimit()<<endl<<"with a charge of $3000 so he cannot make a charge of 3000 dollars "<<endl;
}
cout<<"Just checking prices to see if cost_item function works "<<endl;
cout<<"but not actually purchasing items so the balance is not changed:"<<endl;
cout<<"cost of item that cost $15.00 will cost Leigh - a person so a 5% discount - $"<<Person.cost_item(15.00)<<"."<<endl;
cout<<"cost of item that cost $1000.00 will cost Canaday - a business so a discount of 15% - $"<<Business.cost_item(1000)<<"."<<endl;
cout<<"New monthly balance for Leigh after making a $300.00 payment is $";
Person.New_Balance(300);
cout<<Person.GetBalance();
cout<<endl;
cout<<"New monthly balance for Canaday after make a $2000.00 payment is $";
Business.New_Balance(2000);
cout<<Business.GetBalance()<<"."<<endl;
system("Pause");
return 0;
}
|