Code:
string Bank::listCustomersWithHoldingsAbove(int ammount)
{
string result;
result += "\n";
for (int i = 0; i < vAccount.size(); i++)
{
if (ammount < vAccount[i].balance)
{
result += padRight("", '_', 9) + " ";
result += padRight("", '_', 12) + " ";
result += padRight("", '_', 12) + " ";
result += padRight("", '_', 12) + "\n";
result += padRight("Customer#", '.', 9) + " ";
result += padRight("Name", '.', 12) + " ";
result += padRight("DOB", '.', 12) + " ";
result += padRight("SSN", '.', 12) + "\n";
result += padRight("Account#", '.', 9) + " ";
result += padRight("Account Type", '.', 12) + " ";
result += padRight("Balance", '.', 12) + "\n";
result += padRight(intToString(vCustomer[i].customerNumber), ' ', 9) + " " +
padRight(vCustomer[i].name, ' ', 12) + " " +
padRight(vCustomer[i].birthdate, ' ', 12) + " " +
padRight(vCustomer[i].SSnumber, ' ', 12) + "\n";
result += padRight(intToString(vAccount[i].accountNumber), ' ', 9) + " " +
padRight(vAccount[i].accountType, ' ', 12) + " " +
padRight(intToDollarString(vAccount[i].balance), ' ', 12) + "\n";
result += padRight("", '_', 9) + " ";
result += padRight("", '_', 12) + " ";
result += padRight("", '_', 12) + " ";
result += padRight("", '_', 12) + "\n";
return "These customers have their account balance higher than: " + intToDollarString(ammount) + "\n" + result;
}
else
{
return "Sorry, you don't have any customers with more than " + intToDollarString(ammount) + " in your bank. \nCongratulations. You're poor.";
}
}
}
For some reason, it stops at the very first account that it sees meet the restriction in this case. When the program opens I have 5 accounts, each with a little more than 10 and one account with over 400 in it. It doesn't run through all of them NOR does it link up with any of the random accounts I add into the program via a separate AddAccounts function.