#include #include #include using namespace std; #include "account-new.h" bool aLowBal(Account & curr) { //cout << " " << curr << endl; if (curr.GetBal() < 500){ //cout << "Count me!" << endl; return true; } else { return false; } } int PickRand(int num) { unsigned int ran = rand(); int answ = ran % num; return answ; } void ShowList (list all) { list::iterator acctItr; for (acctItr = all.begin(); acctItr != all.end(); acctItr++) { cout << *acctItr << endl; } return; } int main () { list accts; for (int cnt = 0; cnt < 5; cnt++) { Account newOne; accts.push_back(newOne); } ShowList(accts); list::iterator acctItr; for (acctItr = accts.begin(); acctItr != accts.end(); acctItr++) { int toDep = PickRand(2000); acctItr->Deposit(toDep); } ShowList(accts); //sort(accts.begin(),accts.end()); accts.sort(); ShowList(accts); int numLoBal = count_if(accts.begin(),accts.end(),aLowBal); cout << "Num Low Bal: " << numLoBal << endl; cout << "first account: "<< accts.front() << endl; cout << "last account: " << accts.back() << endl; if (accts.empty()) { cout << "Empty" << endl; } return 0; }