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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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<iostream>
#include<vector>
#include<string>
#include<list>
#include <iomanip>
using namespace std;

#include"data.cpp"

list<BankXA> *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<BankXA> *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 << setprecision(2);
   
   //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 << endl;  
      
   }
   
   
   return 0;
}
//  ****** CHANGE NOTHING BELOW THIS LINE!!


list<BankXA> *getXAList()
{   
   list<BankXA> *lb=new list<BankXA>;
   
   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<10;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<string>
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.
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.
Transcribed Image 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Types of Database Architectures
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education