Questions
Discuss some characteristics unique to the executive/organizational coaching model. Discuss how coaching and consulting differ from...

Discuss some characteristics unique to the executive/organizational coaching model. Discuss how coaching and consulting differ from each other.

In: Psychology

How do I add an output operator to a class in C++? The specific part of...

How do I add an output operator to a class in C++?

The specific part of the task said to:

Define a ​class t​o hold accounts. Use the ​same​ stream variable! Write getters to access the fields in the accounts when printing. Add an output operator for your class. First, Repeat the print loop using this output operator.Now​ make the output operator a friend, by adding a friend​prototype​ to your account class definition. Add a line in the output operator that prints the fields “directly”, i.e. without using the getters. The vector push_back method will be passed as temporary object defined as the argument to push_back. Repeat the filling of the vector using ​emplace_back ​and again display the contents.

Under my "class AccountClass":

I was supposed to add an "output operator". Based on the instructions above, how do you do this?

Code:

#include
#include
#include
#include
#include
#include

using namespace std;

struct Account
{
   string name;
   int accno;
};

class Transaction
{
private:
   bool isDeposit;
   int amount;
   //Balance need to be static to maintain the state across the transactions
   static int balance;
public:
   void deposit(int amt)
   {
       amount = amt;
       balance += amount;
       isDeposit = true;
   }
   void withdraw(int amt)
   {
       amount = amt;
       balance -= amount;
       isDeposit = false;
   }
};

class AccountClass
{
private:
   string name;
   int accno;
   vector vHistory;
public:
   AccountClass(string nm, int acno) :name(nm), accno(acno)
   {

   }
   string getName()
   {
       return name;
   }

   int getaccno()
   {
       return accno;
   }

   void addTransaction(Transaction t)
   {
       vHistory.push_back(t);
   }
};

void readandDisplayUsingStruct(string fileName= "accounts.txt")
{
   ifstream fin;

   fin.open(fileName);

   if (!fin.is_open())
       return;

   string line;

   vector vAccounts;

   //Read each line from the file
   while (getline(fin, line))
   {
       stringstream ss(line);
       string name;
       int no;
       //Split the line into name and id using string stream
       ss >> name;
       ss >> no;
       Account acc{ name,no };
       vAccounts.push_back(acc);
   }

   cout << "The Read Values are" << endl;

   for (Account acc : vAccounts)
   {
       cout << "Name : " << acc.name << "\n";
       cout << "No : " << acc.accno << "\n";
   }

   //Clear the vector
   vAccounts.clear();

   fin.close();

   //Again do the same operation using local variables without Braces Initialisation.
   fin.open(fileName);

   if (!fin.is_open())
       return;

   string line1;

   vector vAccounts2;

   //Read each line from the file
   while (getline(fin, line1))
   {
       stringstream ss(line1);
       string name;
       int no;
       //Split the line into name and id using string stream
       ss >> name;
       ss >> no;
       Account acc;
       //Explicit initialisation
       acc.name = name;
       acc.accno = no;
       vAccounts2.push_back(acc);
   }

   std::cout << "The Read Values are" << endl;

   for (Account acc : vAccounts)
   {
       std::cout << "Name : " << acc.name << "\n";
       std::cout << "No : " << acc.accno << "\n";
   }

   fin.close();

}

void readandDisplayUsingClass(string fileName)
{
   ifstream fin;

   fin.open(fileName);

   if (!fin.is_open())
       return;

   string line;

   vector vAccounts;

   //Read each line from the file
   while (getline(fin, line))
   {
       stringstream ss(line);
       string name;
       int no;
       //Split the line into name and id using string stream
       ss >> name;
       ss >> no;
       AccountClass acc(name, no);
       vAccounts.push_back(acc);
   }

   std::cout << "The Read Values are" << endl;

   for (AccountClass acc : vAccounts)
   {
       std::cout << "Name : " << acc.getName() << "\n";
       std::cout << "No : " << acc.getaccno() << "\n";
   }

   //Clear the vector
   vAccounts.clear();

   fin.close();

}

int main()
{
   ifstream fin;

   fin.open("transactions.txt");

   if (!fin.is_open())
       return 0;

   string line;

   vector vAccounts;

   //Read each line from the file
   while (getline(fin, line))
   {
       stringstream ss(line);
       string operation;
       if (operation == "Deposit" || operation == "Withdraw")
       {
           int accno;
           ss >> accno;
           auto itr = std::find_if(vAccounts.begin(), vAccounts.end(), [&](AccountClass anAccount)
               {
                   return anAccount.getaccno() == accno;
               });

           if (itr != vAccounts.end())
           {
               Transaction t;
               int amount;
               ss >> amount;

               if (operation == "Deposit")
               {
                   t.deposit(amount);
               }
               else
               {
                   t.withdraw(amount);
               }

               itr->addTransaction(t);
           }
       }
       else if (operation == "Account")
       {
           string accName;
           ss >> accName;
           auto itr = std::find_if(vAccounts.begin(), vAccounts.end(), [&](AccountClass anAccount)
               {
                   return anAccount.getName() == accName;
               });

           if (itr == vAccounts.end())
           {
               int accno;
               ss >> accno;
               AccountClass newAccount(accName, accno);
               vAccounts.push_back(newAccount);
           }

       }

   }
}


Here is more information based on the expert’s comments: (i am just pasting the whole question since you did not specify what info you need, all my code is already posted)

Step 1: Define a ​struct​ that can hold information about bank accounts. First: ■ Each instance will hold the name for the account and an account number. We have created an input file that has at least three accounts, called "accounts.txt":
"moe 6
larry 28
curly 42"
Read a file of account information, filling a vector of account objects. Define local variables corresponding to each data item. Loop through the file, reading into these variables. Clear the vector, reopen the file (call the open method), and​repeat the above, except using curly braced intializers to intialize the instance. Close the file and display all objects.

Step 2: Define a ​class t​o hold accounts. Redo the above steps from task 1 that you did with the struct version. Use the ​same​ stream variable! Write getters to access the fields in the accounts when printing. Add an output operator for your class. First, Repeat the print loop using this output operator.Now​ make the output operator a friend, by adding a friend​prototype​ to your account class definition. Add a line in the output operator that prints the fields “directly”, i.e. without using the getters. The vector push_back method will be passed as temporary object defined as the argument to push_back. Repeat the filling of the vector using ​emplace_back ​and again display the contents.

Step 3: Add ​transactions​ to your world. A transaction will be implemented as a class and have a field to indicate whether this is a deposit or a withdrawal and a field to say how much is being deposited or withdrawn. The account class will keep track of transactions applied to it. It will need a vector to store this history of transactions. It will also need a "balance" field to indicate how much is in the account. The account will have methods "deposit" and "withdrawal" which will be passed the amount and will add an appropriate transaction object to the history and modify the balance as needed. The output operator for the account will need to change so that it can display (you format it) the history, i.e. the transactions. When you finish, test this by reading in another file "transactions.txt" that has commands such as:
"Account moe 6
Deposit 6 10
Withdraw 6 100
Account larry 28
Withdraw 6 100
Deposit 6 10
Deposit 6 10
Withdraw 6 5
Account curly 42"

In: Computer Science

A car accelerates from rest to 60 mph in 4.8 seconds. It then continues at constant...

A car accelerates from rest to 60 mph in 4.8 seconds. It then continues at constant velocity for 10 seconds. Determine the distance in the first part and in the second part. Also, what is the car's acceleration in the first part? In the 2nd part? What is it's velocity at the end of the first part( which is also maximum velocity)? (show all work)

distance1=

distance 2=

accel1=

accel2=

velocity max=

In: Physics

a.) Find the pressure difference on an airplane wing where air flows over the upper surface...

a.) Find the pressure difference on an airplane wing where air flows over the upper surface with a speed of 120 m/s and along the bottom surface with a speed of 90 m/s.
_____ Pa

b.) If the area of the wing is 25 m2, what is the net upward force exerted on the wing?
____ N

(You may assume the density of air is fixed at 1.29 kg/m3 in this problem. Also, you may neglect the thickness of the wing-- though could you incorporate this too, if it was given?)

The answer is NOT a) 3.4x10^4 and b) 8.5 x 10^5. These were both incorrect.

In: Physics

Martin Software has 11.4 percent coupon bonds on the market with 18 years to maturity. The...

Martin Software has 11.4 percent coupon bonds on the market with 18 years to maturity. The bonds make semiannual payments and currently sell for 108.5 percent of par.

What is the current yield on the bonds?

What is the YTM?

What is the effective annual yield?

In: Finance

Fincher Manufacturing (FM) is considering two mutually exclusive capital investments to utilize an idle factory owned...

Fincher Manufacturing (FM) is considering two mutually exclusive capital investments to
utilize an idle factory owned by the firm. The first alternative calls for manufacturing tundratorque drill bits required for the extraction of rare earth metals from the frozen tundra of
Greenland. This proposal would generate after-tax cash inflows of $12 million per year
beginning in one year (at date 1). Due to the current scarcity of rare earth metals, the yearly
cash flows for this project are expected to grow by 5 percent per year in perpetuity from date
1 on. The second alternative calls for producing the Polycrystalline Diamond Compact bits
frequently used in horizontal drilling operations. Alternative two will generate constant
yearly after-tax cash flows of $20 million beginning in one year (at date 1) and remaining
constant in perpetuity. Assuming each project requires an initial investment of $120 million:
a. Which capital investment project has the greater IRR?

b. Which project has a greater NPV if Fincher’s cost of capital is 10 percent.

c. Determine the range of estimates for Fincher’s cost of capital for which investing in the
project having the greater IRR maximizes the value of the firm.

In: Finance

Quincy Durant, who had his 75th birthday last month, has been offered a reverse mortgage by...

Quincy Durant, who had his 75th birthday last month, has been offered a reverse mortgage by the Selleck National Bank. The terms of the reverse mortgage call for Mr. Durant to receive a fixed monthly income payment over his remaining 10-year life expectancy, with the monthly income payment being determined by setting the future value of the monthly payments to be received by Mr. Durant equal to 90 percent of the current $400,000 value of his home. At the end of 10 years Mr. Durant expects to sell his home and repay these monthly payments along with the accrued interest on his monthly borrowings over the previous 10 years. Assuming that that the interest rate on the reverse mortgage is 4.20 percent, compare the monthly amount that Mr. Durant will receive from the reverse mortgage with the monthly payment for a conventional 10-year mortgage loan in the amount of $360,000 with a monthly compounded interest rate of 4.20 percent.?

In: Finance

Provide a description of the try .. catch statement. As part of your description you must...

Provide a description of the try .. catch statement. As part of your description you must describe how this statement can be used to handle errors and exceptions and include an example of try ... catch implemented to handle an error or exception within a Java program.

Please Don't copy from someone else.

In: Computer Science

1. Consider the seven missteps mentioned in How to mess up your agile transformation in seven...

1. Consider the seven missteps mentioned in How to mess up your agile transformation in seven easy (mis)step. The concepts Handscomb discusses in each of the missteps do have much validity. Can you think of any modern day examples of firms and/or projects that have exhibited these pitfalls? In addition, what would you have done differently?

In: Operations Management

Explain how increased technology has aided sports organizations in minimizing expenses.

Explain how increased technology has aided sports organizations in minimizing expenses.

In: Finance

Python I am creating a class in python. Here is my code below: import csv import...

Python

I am creating a class in python. Here is my code below:

import csv

import json

population = list()
with open('PopChange.csv', 'r') as p:
reader = csv.reader(p)
next(reader)
for line in reader:
population.append(obj.POP(line))
population.append(obj.POP(line))

class POP:
""" Extract the data """
def __init__(self, line):
self.data = line
# get elements
self.id = self.data[0].strip()
self.geography = self.data[1].strip()
self.targetGeoId = self.data[2].strip()
self.targetGeoId2 = self.data[3].strip()
self.popApr1 = self.data[4].strip()
self.popJul1 = self.data[5].strip()
self.changePop = self.data[6].strip()

The problem is, I get an error saying:  

population.append(obj.POP(line))
NameError: name 'obj' is not defined

What is causing this error? Is it a module I need to import or if I do need to assign obj to something, what am I supposed to assign it to?

What I am trying to do is create a program that allows a user to load a csv file and then print the statistics of the column in the csv chosen, such as the count, mean, standard deviation, min, max, and plot a histogram.

In: Computer Science

Choose a recent food recall or restaurant food safety news story. Recent popular stories include the...

Choose a recent food recall or restaurant food safety news story. Recent popular stories include the romaine lettuce recall, the chipotle food safety outbreak etc. Describe the cause of the incident and how they were able to trace it to the source. What illness did this lead to ?

approximately 300 words thank you

sources should be cited please

In: Psychology

Based on the course learning objectives listed below, explain the most important concepts you learned from...

Based on the course learning objectives listed below, explain the most important concepts you learned from this course and how you think you might apply these concepts in your future career? Course Objectives Outline a communication plan for a public health emergency. Identify factors involved in risk communication. Outline the principles of modern quarantine. Summarize responses to pandemics.

  • Outline a communication plan for a public health emergency.
  • Identify factors involved in risk communication.
  • Outline the principles of modern quarantine.
  • Summarize responses to pandemics.

In: Economics

Completely and thoroughly explain how any type of Work Measurement Technique was used to determine the...

Completely and thoroughly explain how any type of Work Measurement Technique was used to determine the labor cost of their services by any Service Company that provides any type of service to its customers. A service company is any company that does some type of work for a customer, such a lawn maintenance, and although they may also include some products, such as applying fertilizer to the lawn, their primary function is providing the service, such as keeping the lawn, hedges, and flowers in an attractive condition.

In: Operations Management

Rosewell Company has had 5,000 shares of 9%, $100 par-value preferred stock and 10,000 shares of...

Rosewell Company has had 5,000 shares of 9%, $100 par-value preferred stock and 10,000 shares of $10 par-value common stock outstanding for the last two years. During the most recent year, dividends paid totaled $65,000; in the prior year, dividends paid totaled $40,000.
Required: Compute the amount of dividends that must have been paid to preferred stockholders and common stockholders in each year, given the following independent assumptions:
e. Preferred stock is fully participating and cumulative.
f. Preferred stock is nonparticipating noncumulative.
g. Preferred stock participates up to 10% of its par value and is cumulative.
h. Preferred stock is nonparticipating and cumulative.

In: Finance