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
|
# include <iostream>
using namespace std;
const int maxAccounts = 10;
//savings account class
class savingsAccount
{
//private data kept encapsulated here (account numbers, balances and interest rate)
private:
int accountNum;
float balance;
float iRate;
//accessor functions
public:
void displayBalance () const;
};
int main ()
{
//variables
float iRate = 0.05;
int pos;
//initializing struct savingsAccount
savingsAccount accnts[maxAccounts] =
{
123456,0.0,iRate,
246890,0.0,iRate,
937568,0.0,iRate,
337761,0.0,iRate,
846579,0.0,iRate,
293567,0.0,iRate,
917355,0.0,iRate
};
savingsAccount.displayBalance();
system("pause");
return 0;
}
void savingsAccount::displayBalance()
{
for (int count = 0; count < 7; count++)
cout << "The account number is: " << accnts[count].accountNum << "The balance for this account is: $" << accnts[count].balance;
}
|