Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem statement: You are tasked with writing a program which will write a mont

ID: 3773257 • Letter: P

Question

Problem statement: You are tasked with writing a program which will write a monthly account summary of customers' transactions at the bank at which you are employed.The monthly transactions are stored in a file called transactions.txt in the follow form: 123 d45.10 d50.45 d198.56 w45.67 The first entry is the account number; the remainder of the line, variable in length, contains all the transactions of the particular customer for the month: If the entry begins with a d, the number that follows is the amount of deposit If it begins with a w, the number that follows is the amount of withdraw. The customer "database" is stored in another file, accounts.txt which has entries of the form 123 daffy 34.67 where each line contains the customer's account number then their name, followed by the current account balance at the beginning of the month. Your program will write report in the following form ( given the above data ) Account Number 123 Name daffy Beginning Balance : $34.67 Ending Balance : $283.11 Amount Deposited : $294.11 Number of Deposits : 3 Amount Withdrawn : $45.67 Number of Withdraw 1 The report is to be written to a file called account_report_MONTH.txt, where MONTH is a user entered month name CODE: Your program will read from the following files: a file containing the listing of all transactions for the month; a file containing a list of all customers, along with their account ids. You must use the following structure to hold the data of each customer: struct PersonAcct // struct account holds customer info { int acct_num; // customer account number string name; // customers name int acct_bal; // customers account balance } Here are the two text files: accounts.txt 123 daffy 34.67 345 goofy 123.89 639 sneezy 1945.76 890 dopey 12345667.90 666 grumpy 666.66 transactions.txt 123 d45.10 d50.45 d198.56 w45.67 345 w34.00 d4.56 w45.13 d23.23 w23.12 639 d1000.34 d1234.56 w34.33 w345.87 w22.13 890 d345.67 d123.67 d45.99 d45.99 w34.77 666 d66.60 d666.66 d6.66 d66.6 d6666.66 Using visual studio c++. Also note to anyhelp out there if you do not have screen shot of your code output. Do not attempt to answer this question. There are lots of so call folks that are answering wrongly.

Explanation / Answer

working code for bank account.

It will reading the transaction file and will update the account.

#include <fstream>
#include <iostream>
#include <string.h>
#include <stdlib.h>


class BankAccount
{
public:
BankAccount();
virtual ~BankAccount(){}
BankAccount(int currentBalance);
void deposit(int amount);
void withdraw(int amount);
int getCurrentBalance();
int getNumberOfTransactions();
protected:
private:
int currentBalance;
int numberOfTransactions;
};

BankAccount::BankAccount()
{
currentBalance = 1000;
numberOfTransactions = 0;
}
  
BankAccount::BankAccount(int pCurrentBalance)
{
currentBalance = pCurrentBalance;
numberOfTransactions = 0;
}

void BankAccount::deposit(int amount)
{
currentBalance += amount;
numberOfTransactions++;
}

void BankAccount::withdraw(int amount)
{
if (currentBalance >= amount)
{
currentBalance -= amount;
}
else
{
std::cout << "ERROR: Cannot withdraw " << amount << " since current balance is " << currentBalance << std::endl;
}
numberOfTransactions++;
}

int BankAccount::getCurrentBalance()
{
return currentBalance;
}

int BankAccount::getNumberOfTransactions()
{
return numberOfTransactions;
}

int main()
{
std::string line;
char temp[1024];
int initialCurrentBalance;
std::ifstream transactions;
std::ofstream output;

transactions.open("transactions.txt");
output.open("output.txt");

std::cin >> initialCurrentBalance;

BankAccount backAccount(initialCurrentBalance);

char * key_ch;
  
while (!transactions.eof())
{
getline (transactions, line);
memset(temp, 0, sizeof(temp));
strncpy(temp, line.c_str(), sizeof(temp));
output << temp << std::endl;
key_ch = strtok(temp, " ");
while ( key_ch != NULL)
{
if (strcmp(key_ch, "w") == 0)
{
key_ch = strtok(NULL, " ");
backAccount.withdraw(atoi(key_ch));
}
else if (strcmp(key_ch, "d") == 0)
{
key_ch = strtok(NULL, " ");
backAccount.deposit(atoi(key_ch));
}
else
{
key_ch = strtok(NULL, " ");
= }
}
}

transactions.close();
output << "Current Balance is $" << backAccount.getCurrentBalance() << std::endl;
output << "Number Of Transactions is " << backAccount.getNumberOfTransactions() << std::endl;
output.close();   
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote