I\'m working on a project and having some trouble with it. It seems chegg wont l
ID: 3540018 • Letter: I
Question
I'm working on a project and having some trouble with it. It seems chegg wont let me post a big question since errors pop up.
Here are the layouts provided:
BankingSystem.h
#ifndef _BANKINGSYSTEM_H
#define _BANKINGSYSTEM_H
#include <iostream>
#include <string>
#include <cstdlib>
//Class Account holds an account ID, passcode,
//first name, last name, and balance. All variables
//are kept private. Access/changes are made through
//public set and get functions.
class Account
{
public:
void SetAccountID(unsigned accountID);
unsigned GetAccountID();
void SetPasscode(unsigned passcode);
unsigned GetPasscode();
void SetFirstName(const std::string& firstName);
std::string GetFirstName();
void SetLastName(const std::string& lastName);
std::string GetLastName();
void SetBalance(double balance);
double GetBalance();
private:
unsigned accountID_;
unsigned passcode_;
std::string firstName_;
std::string lastName_;
double balance_;
};
//Assume a max of 100 accounts.
const size_t MAX_NUM_ACCOUNTS = 100;
//Class BankingSystem uses an array of Account.
//You can create, delete, print, deposit, and withdraw.
class BankingSystem
{
public:
BankingSystem();
void CreateAccount();
void DeleteAccount();
void PrintAccounts();
void Deposit();
void Withdraw();
private:
Account accounts_[MAX_NUM_ACCOUNTS];
size_t current_num_accounts_;
//Use these auxiliary functions if you want.
//See bankingSystem.cpp for more info.
size_t FindAccount(unsigned accountID);
bool MatchPasscode(unsigned passcode, size_t index);
};
#endif
BankingSystem.cpp
#ifndef _BANKINGSYSTEM_CPP
#define _BANKINGSYSTEM_CPP
#include <iostream>
#include <string>
#include <cstdlib>
#include "bankingSystem.h"
void Account::SetAccountID(unsigned accountID)
{
accountID_ = accountID;
}
unsigned Account::GetAccountID()
{
return accountID_;
}
//*** TO DO: Add the rest of your Account function implementations here.
//Default constructor just initializes
//current number of accounts to 0;
BankingSystem::BankingSystem() : current_num_accounts_(0)
{}
//Find an account by accountID.
//Return the array index if found, current_num_accounts_ otherwise.
size_t BankingSystem::FindAccount(size_t accountID)
{
for (size_t i = 0; i < current_num_accounts_; ++i)
if (accounts_[i].GetAccountID() == accountID)
return i;
return current_num_accounts_;
}
//Match the passcode at a given index with the given passcode.
//Return true for a match, false otherwise.
bool BankingSystem::MatchPasscode(unsigned passcode, size_t index)
{
return accounts_[index].GetPasscode() == passcode;
}
//Add an account.
void BankingSystem::CreateAccount()
{
Account account;
unsigned accountID;
unsigned passcode;
std::string firstName;
std::string lastName;
double balance;
//Get the account ID and make sure it doesn't already exist.
std::cout << " Enter the account ID: ";
std::cin >> accountID;
if (FindAccount(accountID) != current_num_accounts_)
{
std::cout << " Account already exists! ";
return;
}
//*** TO DO: Get the remaining items (passcode, first name, last name, balance).
//Set this info into your Account object.
account.SetAccountID(accountID);
account.SetPasscode(passcode);
account.SetFirstName(firstName);
account.SetLastName(lastName);
account.SetBalance(balance);
//Add the account to your array and increment the count of accounts.
accounts_[current_num_accounts_] = account;
++current_num_accounts_;
std::cout << " Account added successfully! ";
}
//Delete an account.
void BankingSystem::DeleteAccount()
{
size_t index;
unsigned accountID;
unsigned passcode;
//*** TO DO: Get the account ID and verify it exists.
//*** TO DO: Get the passcode and verify it matches.
//Remove the account. First, shift everything over to the left.
for (size_t i = index; i < current_num_accounts_ - 1; ++i)
accounts_[i] = accounts_[i + 1];
//Then, decrement the count of accounts.
--current_num_accounts_;
std::cout << " Account erased! ";
}
//*** TO DO: Add your remaining BankingSystem function implementations here.
#endif
BankingSystemDriver.cpp
#include <iostream>
#include "bankingSystem.h"
//Print a menu of options to the user.
void PrintMenu()
{
std::cout << " (1) Add Account ";
std::cout << "(2) Delete Account ";
std::cout << "(3) Print Accounts ";
std::cout << "(4) Deposit ";
std::cout << "(5) Withdrawal ";
std::cout << "(6) Exit ";
std::cout << " Enter selection: ";
}
//Start your main program loop here.
int main()
{
//All class functions are called through a BankingSystem object.
BankingSystem b;
int selection;
std::cout << " *** Welcome to the Banking System *** ";
//*** TO DO: Add a loop that prints a menu and
//processes the user's selection.
return 0;
}
Explanation / Answer
USE FULL HEADER FILES I.E IOSTREAM.H
your PROGRAMMING IS ABSOLUTELY CORRECT I HAVE RUN THIS PROGRAM.....NO ERRORS FOUND..
IF ANY QUERYPLZZ ASK