Would someone please point me in the right direction on this assignment? I need to help getting started with this banking program that has both deposit method and a withdraw method.after creating the account, the user is prompted to deposit or withdraw an amount of money.the modified account balance needs to be stored into the data file. Any help is greatly appreciated
#include <iostream>
#include <string>
#include <fstream>
#include "dataStore.hpp"
#include "account.hpp"
usingnamespace std;
int main()
{
char more = 'y';
string accountHolderName= " ";
dataStore *accountStorage;
account *newAccount;
string decision="" ;
// Create a data storage file object.
accountStorage = new dataStore();
// Loop on user continuing
while(more == 'y')
{
// ask for account owner's name
cout << "What is the account holder's name: ";
cin >> accountHolderName;
//Ask user if they want to deposit or withdraw money
cout << "Would you like to deposit or withdraw money?";
cin>> decision;
// Create an account object
newAccount = new account(accountHolderName);
// store the account on the data storage file
accountStorage->save(newAccount);
// Ask user if any more accounts
cout << "Any more accounts to create? ";
cin >> more;
}
return 0;
}}
#include "account.hpp"
#include <string>
usingnamespace std;
account::account(string owner)
{
accountOwnerName = owner;
balance = 0.00;
}
account::~account(void)
{
}
double account::getBalance(void)
{
return balance;
}
string account::getOwnerName(void)
{
return accountOwnerName;
}
//The method to deposit
if (decision(void) = "deposit")
{
// ask the user how much would they like to deposit
// add the deposit amount to the current balance
}
//The method to withdraw
if (decision(void)= "withdraw")
{
//ask the user how much they would like to withdraw
// subtract the withdraw amount from the current balance
//(if statment) --> if the withdraw is more than the current balance you send the user a message that they do not have enough
}
#ifndef accountheaderforaccountclass
#define accountheaderforaccountclass
#include <string>
usingnamespace std;
class account
{
public:
account(string);
~account(void);
double getBalance(void);
string getOwnerName(void);
// string decision= "" (void);
double withdraw;
double deposit;
private:
string accountOwnerName;
double balance;
};
#endif
#include "dataStore.hpp"
#include <string>
usingnamespace std;
dataStore::dataStore(void)
{
store.open("BankAccountData.txt", ios::app);
}
dataStore::~dataStore(void)
{
store.close();
}
void dataStore::save(account *newAcct)
{
store << newAcct->getOwnerName() << newAcct->getBalance() << endl;
}
#include "dataStore.hpp"
#include <string>
usingnamespace std;
dataStore::dataStore(void)
{
store.open("BankAccountData.txt", ios::app);
}
dataStore::~dataStore(void)
{
store.close();
}
void dataStore::save(account *newAcct)
{
store << newAcct->getOwnerName() << newAcct->getBalance() << endl;
}
#include "Account.hpp"
#include <iostream>
Account::Account(std::string owner)
: owner_name { owner },
balance { 0.0 }
{
}
double Account::getBalance() const
{
return balance;
}
std::string Account::getOwnerName() const
{
return owner_name;
}
void Account::deposit(double amount)
{
// if amount == 0.0, prompt the user about how much money
// increase balance by the proper amount
}
void Account::withdraw(double amount)
{
// check if there's money on the account?
// if amount == 0.0, prompt the user about how much money
// decrease balance by the proper amount
}
// Would someone please point me in the right direction on this assignment?
// I need to help getting started with this banking program that has both
// deposit method and a withdraw method.
// after creating the account, the user is prompted to deposit or withdraw an
// amount of money.
// the modified account balance needs to be stored into the data file.
// Any help is greatly appreciated
#include "Account.hpp"
#include "DataStore.hpp"
#include <iostream>
#include <string>
int main()
{
char more { 'y' };
while(more == 'y')
{
std::cout << "What is the account holder's name: ";
std::string accountHolderName;
std::cin >> accountHolderName;
// Create an account object
Account account(accountHolderName);
std::cout << "Your balance is now " << account.getBalance() << '\n';
//Ask user if they want to deposit or withdraw money
char decision {};
do {
std::cout << "Would you like to (D)eposit or (W)ithdraw money (D/W)? ";
std::cin >> decision;
} while(decision != 'D' && decision != 'W');
if(decision == 'D') {
// call the proper Account method
// Create a data storage file object.
DataStore account_storage;
// store the account on the data storage file
account_storage.save(account);
// Ask user if any more accounts
std::cout << "Any more accounts to create? ";
std::cin >> more;
}
return 0;
}
Please consider ‘forum’ is a Latin word which used to mean just ‘square’, i.e. a place where people could freely meet and talk. When you post on a free forum, you can get a good answer, a bad answer or no answer at all. It happens. Is up to you to make your question interesting.