The code below compiles properly, but the calculation seems to be an issue. When printing out the first deduction 'withdraw', the customerBalance is 2.07361e (8032.78 - 244.0 = 7788.78)? The data members are private, but it didn't appear to be an issue with it being public or private. I'm not sure. Any suggestions would be welcome. Thank you.
#include <iostream>
#include "BankAccount.hpp"
using namespace std;
BankAccount::BankAccount(string name, string ID, double balance)
{
customerName = name;
customerID = ID;
customerBalance = balance;
}
string BankAccount::getCustomerName()
{
return customerName;
}
string BankAccount::getCustomerID()
{
return customerID;
}
double BankAccount::getCustomerBalance()
{
return customerBalance;
}
void BankAccount::withdraw(double w)
{
customerBalance = (customerBalance - w);
}
void BankAccount::deposit(double d)
{
customerBalance = (customerBalance + d);
}
int main()
{
double customerBalance;
BankAccount account1("Harry Potter", "K4637", 8032.78);
account1.withdraw(244.0);
cout << customerBalance;
account1.withdraw(3012.58);
account1.deposit(37.54);
account1.withdraw(1807.12);
account1.deposit(500.00);
double finalBalance = account1.getCustomerBalance();
}