****C++ 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. #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 << setprecision(2); //3 Create a for loop to use the iterBank iterator { //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 *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<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; } #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++
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.
#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
{
//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;
}
#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){}
};
Step by step
Solved in 4 steps with 3 images