So, I've got my program up and running, and everything is great except my problem is I can't figure out why my output for my original balance and my output for my new balance are the same and it won't do my calculation

Here is my header

#ifndef SavingsAccount_H
#define SavingsAccount_H

#include <string>
using namespace std;

class SavingsAccount
{
public:
	SavingsAccount();
	SavingsAccount(string, string);
	SavingsAccount(string, string, double);
	~SavingsAccount();

	void setFirstName(string);
	void setLastName(string);
	void setSavingsBalance(double);
	string getFirstName() const;
	string getLastName() const;
	double  getSavingsBalance() const;

	void printInfo();
	int getNumber() const;
	int getObjCount();

	static double getIntrestRate();
	void static setIntrestRate(double);

	void CalculateNewBalance();

private: 
	string FirstName;
	string LastName;
	double SavingsBalance;
	static double AnnualIntrestRate;
	static int objcount;
	const int ObjectNumber;
};

#endif

Here are my member functions

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include "SavingsAccount.h"

using namespace std;
double SavingsAccount::AnnualIntrestRate = .05;
int SavingsAccount::objcount = 0;

SavingsAccount::SavingsAccount():ObjectNumber(++objcount)
{
	FirstName = LastName = "";
	SavingsBalance = 0;
}

SavingsAccount::SavingsAccount(string First, string Last):ObjectNumber(++objcount)
{
	setFirstName(First); 
	setLastName(Last); 
	setSavingsBalance(0);
}

SavingsAccount::SavingsAccount(string First, string Last, double Balance):ObjectNumber(++objcount)
{
	setFirstName(First); 
	setLastName(Last); 
	setSavingsBalance(Balance);
}

void SavingsAccount::setFirstName(string First)
{
	FirstName = First;
}

void SavingsAccount::setLastName(string Last)
{
	LastName = Last;
}

void SavingsAccount::setSavingsBalance(double Balance) 
{
	SavingsBalance = Balance;
}

void SavingsAccount::setIntrestRate(double Intrest)
{
	AnnualIntrestRate = Intrest;
}
 
string SavingsAccount::getFirstName() const
{
	return FirstName;
}

string SavingsAccount::getLastName() const
{
	return LastName;
}

double SavingsAccount::getIntrestRate()
{
	return AnnualIntrestRate;
}

double SavingsAccount::getSavingsBalance() const
{
	return SavingsBalance;
}

int SavingsAccount::getNumber() const
{
	return ObjectNumber;
}

void SavingsAccount::CalculateNewBalance() // Won't output new data.
{
	SavingsBalance = SavingsBalance + SavingsBalance * AnnualIntrestRate / 12;
}

void SavingsAccount::printInfo()
{
	cout << "The users serial number is " << ObjectNumber << "." << endl << "The users first name is " << FirstName << "." << endl << "The users last name is " << LastName << "." << endl;
	cout << "The users starting balance is $" << SavingsBalance << "." << endl << "The users new savings balance is " << SavingsBalance << endl << endl;
}


SavingsAccount::~SavingsAccount()
{

	cout << "The object with a first name of  " << FirstName << " and a last name of " << LastName << " and a serial number of " << ObjectNumber << " has gone out of scope. " << endl << endl;
}

int SavingsAccount::getObjCount()
{
	return objcount;
}

Here is my main

#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include "SavingsAccount.h"

using namespace std;

int main()
{
	cout << setprecision(2) << fixed;

	SavingsAccount SaverOne("Margaret" , "Olson", 2000.00);
	SavingsAccount SaverTwo("Debra" , "Baxter");
	SavingsAccount SaverThree("", "");

	SaverTwo.setSavingsBalance(5000.00);

	SaverThree.setFirstName("Aruro");
	SaverThree.setLastName("Ortiz");
	SaverThree.setSavingsBalance(10000.00);

	cout << "The first users information is " << endl;
	SaverOne.printInfo();

	cout << "The second users information is " << endl;
	SaverTwo.printInfo();

	cout << "The third users information is " << endl;
	SaverThree.printInfo();

	SavingsAccount::setIntrestRate(.10);

	SaverTwo.setSavingsBalance(2000.00);
	SaverTwo.setSavingsBalance(5000.00);
	SaverThree.setSavingsBalance(10000.00);

	cout << "The first users information is " << endl;
	SaverOne.printInfo();

	cout << "The second users information is " << endl;
	SaverTwo.printInfo();

	cout << "The third users information is " << endl;
	SaverThree.printInfo();

}

And here is my output with the problem circled in red.
http://imgur.com/XZekI

Member Avatar for MonsieurPointer

I'm guessing its because you never called SavingsAccount::CalculateNewBalance() in your code.

That was exactly it :) got it figured out a bit ago, I kept thinking I was missing something with the static variables for some reason.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.