Question: I'm getting the following compilation errors in my C++ program. Thanks in advance for your help. ************** BELOW: Compilation Errors. ************************* $g++ Bank.cpp Bank.cpp: In
I'm getting the following compilation errors in my C++ program. Thanks in advance for your help.
************** BELOW: Compilation Errors. *************************
$g++ Bank.cpp
Bank.cpp: In function int main(int, const char**):
Bank.cpp:72:122: error: transform was not declared in this scope
transform(currentAccountName.begin(), currentAccountName.end(), currentAccountName.begin(), ::tolower);
^
Bank.cpp:86:128: error: transform was not declared in this scope
transform(currentAccountNumber.begin(), currentAccountNumber.end(), currentAccountNumber.begin(), ::tolower);
^
************** BELOW: Bank.cpp *************************
#include "ATM.h" #include "ATM.cpp" #include
void printAccount(ATM account);
int main(int argc, char const *argv[]) {
int numOfAccounts = 10; ATM* accounts = new ATM[numOfAccounts]; int input;
do {
// Prompt User cout << "Welcome to Bank Of The Student\'s! "; cout << "How may I help you today "; cout << "Enter Number To Make Choice (-1 to Exit Program) ";
// Present Menu if (accounts[0].getName() == "" && accounts[0].getAccountNumber() == "") { cout << "1. Create Account "; }else { cout << "1. Create Account "; cout << "2. Already Have An Account "; }
cin >> input;
if(input == 1){ string name; string accountNumber; float balance;
cout << "Enter Full Name: "; getline(cin,name);
cout << "Enter Account Number: "; getline(cin, accountNumber);
cout << "Enter Your Balance: "; cin >> balance;
ATM newAccount = ATM(name,accountNumber,balance);
// Search for empty slot for(int i = 0;i < numOfAccounts;i++){ if (accounts[i].getName() == "") { accounts[i] = newAccount; break; } }
printAccount(newAccount); }else if (input == 2) { int bankInput; cout << "Enter Number To Make Choice "; cout << "1. Enter Name: "; cout << "2. Enter Account Number: ";
cin >> bankInput; if (bankInput == 1) { string name; cin >> name; // Search for person name in array for(int i = 0;i < numOfAccounts;i++){ string currentAccountName = accounts[i].getName(); transform(currentAccountName.begin(), currentAccountName.end(), currentAccountName.begin(), ::tolower); transform(name.begin(), name.end(), name.begin(), ::tolower); if (currentAccountName == name) { printAccount(accounts[i]); break; } } } else if (bankInput == 2) { string accountNumber; cin >> accountNumber;
// Search for person account number in array for(int i = 0;i < numOfAccounts;i++){ string currentAccountNumber = accounts[i].getName(); transform(currentAccountNumber.begin(), currentAccountNumber.end(), currentAccountNumber.begin(), ::tolower); transform(accountNumber.begin(), accountNumber.end(), accountNumber.begin(), ::tolower); if (currentAccountNumber == accountNumber) { printAccount(accounts[i]); break; } } } }else { break; } }while (input != -1); return 0; }
void printAccount(ATM account){ cout << "Account Name: " << account.getName() << endl; cout << "Account Number: " << account.getAccountNumber() << endl; cout << "Balance: $ " << account.getBalance() << endl << endl << endl; }
************** BELOW: ATM.cpp *************************
#include "ATM.h" #include
using namespace std;
ATM::ATM(){ this->name = ""; this->accountNumber = ""; this->balance = 0.0; }
ATM::ATM(string name,string accountNumber,float balance){ this->name = name; this->accountNumber = accountNumber; this->balance = balance; }
// Setters void ATM::setName(string name){ this->name = name; }
void ATM::setAccountNumber(string accountNumber){ this->accountNumber = accountNumber; }
void ATM::setBalance(float balance){ this->balance = balance; }
// Getters string ATM::getName(){ return this->name; }
string ATM::getAccountNumber(){ return this->accountNumber; }
float ATM::getBalance(){ return this->balance; }
// Helpers void ATM::deposit(float deposit){ this->lastDeposit = deposit; setBalance(deposit + this->balance); }
void ATM::withdraw(float withdraw){ if(this->balance <= 0.0){ cout << "Insuffecent Funds" << endl; }else if ((withdraw - this->balance) < 0.0) { this->lastWithdraw = this->balance; setBalance(0.0); }else{ setBalance(withdraw - this->balance); } }
************** BELOW: ATM.h *************************
#ifndef ATM_H_ #define ATM_H_
#include
class ATM {
// Private Members private: string name; string accountNumber; float balance; float lastDeposit; float lastWithdraw;
public: // Constructors ATM(); ATM(string,string,float);
// Setters void setName(string); void setAccountNumber(string); void setBalance(float);
// Getters string getName(); string getAccountNumber(); float getBalance();
// Helper Methods void deposit(float); void withdraw(float);
};
#endif
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
