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
|
#include "CheckingAccount.h"
#include "SavingsAccount.h"
#include <iostream>
using namespace std;
int main() {
Person jack("Jack");
Person lisa("Lisa");
Person omar("Omar");
Person rita("Rita");
double minBalance = 1000;
double charge = 40;
CheckingAccount ca1(1000, 1050, jack, minBalance, charge);// Don't take service charge yet until called for.
CheckingAccount ca2(1001, 450, lisa, minBalance, charge);
CheckingAccount ca3(1002, 930, omar, minBalance, charge);
CheckingAccount ca4(1003, 32, rita, minBalance, charge);
cout<<"Minimum balance should be $1000 dollars and service charge is $40."<<endl<<endl;
SavingsAccount sa1(2000, 1000, jack, .04);//created Savings Account
SavingsAccount sa2(2001, 2000, lisa, .07);
SavingsAccount sa3(2002, 1600, omar, .05);
SavingsAccount sa4(2003, 500, rita, .03);
ca1.withdrawMoney(120);
sa4.withdrawMoney(90);
ca2.withdrawMoney(120);
ca3.depositMoney(290);
sa1.postInterest();
sa2.postInterest();
sa3.postInterest();
sa4.postInterest();
cout<<"Verify whether the balance is less than the minimum balance of $1000 or not. If less, deduct $40"<<endl<<endl;
cout<<ca1.getBalance()<<endl;
cout<<ca2.getBalance()<<endl;
cout<<ca3.getBalance()<<endl;
cout<<ca4.getBalance()<<endl;
if(ca1.getBalance() < minBalance){charge = 40; cout<<ca1.getBalance() - charge<<endl;}//this is the part I need to change but my output is always $40 when it isn't supposed to be. How do I change that to not post $40 when it isn't supposed to?
else charge = 0;
if(ca2.getBalance() < minBalance){charge = 40; cout<<ca2.getBalance() - charge<<endl;}
else charge = 0;
if(ca3.getBalance() < minBalance){charge = 40; cout<<ca3.getBalance() - charge<<endl;}
else charge = 0;
if(ca4.getBalance() < minBalance){charge = 40; cout<<ca4.getBalance() - charge<<endl;}
else charge = 0;
ca1.depositMoney(1000);
sa2.depositMoney(2300);
ca3.depositMoney(800);
sa4.depositMoney(500);
cout << endl << "Checking Account Information"<<endl;
ca1.printInfo();
ca2.printInfo();
ca3.printInfo();
ca4.printInfo();
/*sa1.setInterestEarned(sa1.getInterestRate());
sa2.setInterestEarned(sa2.getInterestRate());
sa3.setInterestEarned(sa3.getInterestRate());
sa4.setInterestEarned(sa4.getInterestRate());
cout<<endl<<"Savings Account Information"<<endl;
sa1.printInfo();
sa2.printInfo();
sa3.printInfo();
sa4.printInfo();*/
system("pause");
return 0;
}
|