This exercise will be about processing a collection of bank transactions using an iterator. A particular account owner may have multiple transactions. Assume a classed named BankXA that contains info...


This exercise will be about processing a collection of bank transactions using an iterator. A particular account owner may have multiple transactions.


Assume a classed named
BankXA
that contains info about a customer's transaction. The class has 4 public attributes:

string acctOwner
//The name of the account's owner

string xaDetail
//some detail on the transaction

string type
// assume the value will always be either "dep" for a deposit or "withd" for withdrawal, no other values
double amt
//the amount of the transaction. The amount will always be 0 or more


Note that these attributes are
public
therefore you will NOT need setters and getters for this exercise. Your program will obtain a
pointer to a list of BankXA. Your program must iterate the list using an iterator and the result must be like the following:


J. Faune withdrew -$485.00 I. Boesky withdrew -$42885.50 J. Faune deposited +$2.50


Where J. Faune and I. Boesky are the acctOwners,
the
withdrew
and
deposited
refer to the type "dep" for a deposit or "withd" for withdrawal
the
-
and
+
symbols must be added depending on the type
you must manually add the
$
in the output
the amounts refer to the amt attribute. Code is given in the template so that the format will be 2 decimal places. No need for you to do any logic there.


//main.cpp


#include
#include
#include
#include
#include
using namespace std;


#include"data.cpp"


list *getXAList();


// CHANGE NOTHING ABOVE THIS LINE




//Hint, you will need some sort of operator overload function here




int main()
{


   //1 Do NOT change this line.  This retrieves the collection of BankXA
   list *lb=getXAList();

   //2 Create a variable of type iterator to a list of BankXA.
   //You must name the variable iterBank

   //This next line ensures double values are formatted correctly with 2 decimal places
   cout < fixed=""><>

   //3 Create a for loop to use the iterBank iterator
   for(){
      //This next line MUST be the only code in the for loop and must output as required
      cout < *iterbank=""><>

   }


   return 0;
}
//  ****** CHANGE NOTHING BELOW THIS LINE!!




list *getXAList()
{
   list *lb=new list;

   BankXA *bxas=new BankXA[10];bxas[3].type="withd";bxas[0].xaDetail="R. Wade getting some $";
   bxas[0].type="withd";  //dep, withd
   bxas[0].acctOwner="R. Wade";
   bxas[0].amt=45.92;bxas[1].xaDetail="J. Faune getting some $";bxas[4].type="dep";bxas[4].amt=4999.99;
   bxas[1].type="withd";bxas[2].xaDetail="I. Boesky got cashier's check";bxas[1].acctOwner="J. Faune";
   bxas[2].type="withd";bxas[2].acctOwner="I. Boesky";  //dep, withd
   bxas[2].amt=42885.5;bxas[3].xaDetail="S. Ronson getting some $";bxas[3].amt=100.0;bxas[4].xaDetail="E. Thomas cash deposit";
   bxas[5].xaDetail="JJ Jameson cash withdrawal";bxas[3].acctOwner="S. Ronson";\
   bxas[4].acctOwner="E. Thomas";bxas[5].acctOwner="JJ Jameson";
   bxas[5].type="withd";bxas[9].xaDetail="P. Pig";bxas[9].type="dep";bxas[9].amt=.5;
   bxas[5].amt=10000.0;bxas[8].xaDetail="Earl Mason got some $";bxas[8].type="withd";bxas[8].amt=3456.0;
   bxas[7].xaDetail="P. Ferb getting some $";bxas[6].acctOwner="E. Rue";bxas[7].acctOwner="P. Ferb";
   bxas[7].type="withd";bxas[7].amt=1487.0;bxas[6].xaDetail="E. Rue made a cash deposit";bxas[6].type="dep";
   bxas[6].amt=92317.0;bxas[8].acctOwner="E. Mason";bxas[9].acctOwner="P. Pig";
   bxas[1].amt=485.0;

   for(int ii=0;ii<>
      lb->push_back(bxas[ii]);

   lb->push_back(BankXA("Test w/d","test account w/d", "withd", 10.5));
   lb->push_back(BankXA("C. Rock", "C Rock dep", "dep", 10000.75));lb->push_back(BankXA("A. Sheedy", "A. Sheedy Rock dep",
   "dep", 12.95));lb->push_back(BankXA("J. Rockhead", "J. Rockhead got money", "dep", 10.75));
   lb->push_back(BankXA("E. Mason", "w/d", "withd", 20.9));
   lb->push_back(BankXA("F. Stone", "F. Stone dep", "dep", 3));
   lb->push_back(BankXA("P. Pig", "dep", "dep", 3));
   lb->push_back(BankXA("P. Ferb", "dep", "dep", 992.2));
   lb->push_back(BankXA("E. Mason", "dep", "dep", 2113));lb->push_back(BankXA("B. Bragg", "dep", "dep", 213));
   lb->push_back(BankXA("E. Thomas", "dep", "dep", 923));

   return lb;
}


//data.cpp


#include
using namespace std;


class BankXA{
public:

   string xaDetail;
   string type;  //dep, withd
   double amt;

   BankXA():xaDetail(""), type("dep"), amt(0){}

   BankXA(string xd, string ty, double a):xaDetail(xd), type(ty), amt(a){}


};


****C++


1) Don't change this line.<br>This will assign lb to a location that has a list of BankXA.<br>Note<br>that it is a pointer.<br>2) Create a variable of type iterator to a list of BankXA.<br>You must name the variable iterBank.<br>See the line like:<br>cout << fixed << setprecision (2);<br>This line will format any double value outputted with 2 decimal places.<br>Do not change it.<br>3) Create a for loop to use the iterBank iterator created above.<br>The iterator must go through the<br>lb list.<br>{<br>//This next line MUST be the only code in the for loop and must output as required<br>cout << *iterBank << endl;<br>}<br>Running this loop must produce a line of output shown above like:<br>J. Faune withdrew -$485.00<br>etc...<br>See the line:<br>//Hint, you will need some sort of operator overload function here. That will be needed to make<br>the loop code work correctly.<br>

Extracted text: 1) Don't change this line. This will assign lb to a location that has a list of BankXA. Note that it is a pointer. 2) Create a variable of type iterator to a list of BankXA. You must name the variable iterBank. See the line like: cout < fixed="">< setprecision="" (2);="" this="" line="" will="" format="" any="" double="" value="" outputted="" with="" 2="" decimal="" places.="" do="" not="" change="" it.="" 3)="" create="" a="" for="" loop="" to="" use="" the="" iterbank="" iterator="" created="" above.="" the="" iterator="" must="" go="" through="" the="" lb="" list.="" {="" this="" next="" line="" must="" be="" the="" only="" code="" in="" the="" for="" loop="" and="" must="" output="" as="" required="" cout="">< *iterbank="">< endl; } running this loop must produce a line of output shown above like: j. faune withdrew -$485.00 etc... see the line: //hint, you will need some sort of operator overload function here. that will be needed to make the loop code work correctly. endl;="" }="" running="" this="" loop="" must="" produce="" a="" line="" of="" output="" shown="" above="" like:="" j.="" faune="" withdrew="" -$485.00="" etc...="" see="" the="" line:="" hint,="" you="" will="" need="" some="" sort="" of="" operator="" overload="" function="" here.="" that="" will="" be="" needed="" to="" make="" the="" loop="" code="" work="">
Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here