And thisv
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
//
// impSavings.cpp
// Bank Account
//
// Created by user on 10/14/18.
// Copyright © 2018 user. All rights reserved.
//
#include "BankAccountHeader.h"
#include "savingsAccountH.h"
#include <stdio.h>
#include <iostream>
#include <iomanip>
/*
savingsAccount();
void setInterestRate();
void setServiceCharges();
double getAccountBalance2() const;
double getInterestRate() const;
int getServiceCharges() const;
void printAccount() const;
*/
int savingsAccount::accountNumberDefault = 299;
//CONSTRUCTOR
//
savingsAccount::savingsAccount(){
intR = 0.0;
servicecharge = 0.0;
}
//
//
//SET INTEREST RATE
//
void savingsAccount:: setInterestRate(){
if (getAccountBalance() >= 0 && getAccountBalance() <5000 ){
intR = .01;
}
if (getAccountBalance() >= 5000 && getAccountBalance() <10000 ){
intR = .02;
}
else if (getAccountBalance() >= 10000 && getAccountBalance() <25000 ){
intR = .03;
}
else if (getAccountBalance() >= 25000 && getAccountBalance() <50000 ){
intR = .04;
}
else if(getAccountBalance() >= 50000 && getAccountBalance() < 250000){
intR = .07;
}
else if(getAccountBalance() >= 250000 && getAccountBalance() < 1000000){
intR =.09;
}
else if(getAccountBalance() >= 1000000 && getAccountBalance() < 10000000000000000){
intR = .15;
}
} //END SET INTR
//
//
//SET SERVICE CHARGES
void savingsAccount:: setServiceCharges() {
if(accountBalance < 500) {
servicecharge = 10;
}
accountBalance -= 10;
}
//
//
double savingsAccount :: getAccountBalance2() const {
return accountBalance;
}
double savingsAccount :: getInterestRate() const {
return intR;
}
double savingsAccount :: getServiceCharges() const{
return servicecharge;
};
// PRINT ACCOUUNT
//
void savingsAccount :: printAccount() const {
cout << "Name: " << fName << " " << lName << endl;
cout << "Account type: " << accountType << endl;
cout << "Account number: " << accountNumber << endl;;
cout << fixed << setprecision(2);
cout << "Current Balance: " << "$" << accountBalance <<endl;;
cout << endl;
}
//
//
// WITHDRAW FUNCTION
//
void savingsAccount:: withdraw() {
cout << fixed << setprecision(2);
cout << "How much would you like to withdraw? ";
cin >> withdrawal;
accountBalance -= withdrawal;
if( accountBalance < 0){
cout <<"There will be a $25 insufficient funds fee. " << endl << endl ;
accountBalance -= 25.00;
}
cout << "Your new account balance is: " << accountBalance <<endl <<endl;
setInterestRate();
toString = to_string(withdrawal);
toString.erase (toString.find_last_not_of('0') + 3, std::string::npos );
transHistory += "Withdrawal: $" + toString + "\n";
}
//
// END WITHDRAW FUNCTION
//DEPOSIT FUNCTION
//
void savingsAccount:: deposit() {
cout << fixed << setprecision(2);
cout << "How much would you like to deposit? ";
cin >> deposit1;
cout << endl << endl;
accountBalance += deposit1;
cout << "Your new account balance is: " << accountBalance << endl << endl;
setInterestRate();
toString = to_string(deposit1);
toString.erase (toString.find_last_not_of('0') + 3, string::npos );
transHistory += "Deposit: $" + toString + "\n";
} // END DEPOSIT
// SET ACCOUNT NUMBERS
//
void savingsAccount :: setAccountNumberDefault() {
accountNumberDefault++;
}
void savingsAccount:: setAccountNumber() {
accountNumber = accountNumberDefault;
}
//
//
|
And this is my parent class and imp filesvv
//
// Bank Account Header.h
// Bank Account
//
// Created by user on 9/21/18.
// Copyright © 2018 user. All rights reserved.
//
#include <string>
#include <iostream>
using namespace std;
#ifndef BankAccountHeader_h
#define BankAccountHeader_h
class bankAccount {
protected:
static int accountNumberDefault;
string fName;
string lName;
int accountNumber;
string accountType;
double accountBalance;
char cORs;
double withdrawal;
double deposit1;
string transHistory;
string toString;
public:
bankAccount();
//Default constructor
void setAccountBalance(double);
void setNewAccount(string&, string&, int&, string&, double&);
void setChangeAccount(string&, int&, string&, double&, double&);
void setAccountType(string);
void setFirstName(string);
void setLastName(string);
int getAccountNumber() const;
double getAccountBalance() const;
string getAccountType() const;
//OLD FUNCTION:
// void newAccount();
//OTHER FUNCTIONS:
void printAccount() const;
void withdraw();
void deposit();
void printTransHistory() const;
};
#endif /* BankAccountHeaderh */
[/code]
This is the implementation file for the parent class: