Question: #include class Account { public: // member functions accessible by anyone // custom constructor Account(std::string accountName, int startingBalance) : name{accountName} // member initializer list {

 #include class Account { public: // member functions accessible by anyone

#include  class Account { public: // member functions accessible by anyone // custom constructor Account(std::string accountName, int startingBalance) : name{accountName} // member initializer list { if (startingBalance > 0){ balance = startingBalance; } } // default constructor Account() {} // function to add to balance void deposit(int depositAmount){ if (depositAmount > 0){ balance += depositAmount; } } // function to return current balance int getBalance() const { return balance; } // function to set the value of the name void setName(std::string accountName){ name = accountName; } // function to get the value of the name // const -- function cannot modify name std::string getName() const { return name; } private: // data members only accessible by member functions // (and "friend" functions/classes) std::string name; int balance{0}; // default initial value }; 
 #include  #include  #include "Account.h" using namespace std; int main() { Account accountA{"John Doe", 100}; Account accountB{"Jane Doe", -100}; // display initial information cout > depositAmt; accountA.deposit(depositAmt); // use member function cout > depositAmt; accountB.deposit(depositAmt); // use member function // display updated information cout   CSCI 272-Spring 2019 Start with the Account.h and main.cpp files developed in class. 1.1a Add a member function withdraw to the Account class. This function will take one Lab 1 - Introduction to Classes 15 ps parameter for a withdrawal amount. The function should: compare the withdrawal amount passed in to the function to the account's balance if the account balance is greater than or equal to the withdrawal amount, subtract th withdrawal amount from the balance otherwise, display a message that the withdrawal amount is greater than the balance o o 1.1b Test the new withdraw function by modifying the main function code in main.cpp .Print out the balance of the account .Use a withdrawal amount greater than the current balance Print out the balance of the account o Expected result: The balance should be unchanged .Use a withdrawal amount less than the current balance Print out the balance of the account Expected result: The balance should be lowered by the withdrawal amount o Use a withdrawal amount equal to the current balance Print out the balance of the account Expected result: The balance should now be 0. o 1.2a Add a member function accountInfo to the Account class. This function will take no parameters. The function should: call the getName and getBalance functions and print out the results how the information is printed is up to you, but both the name and balance values should display, along with some descriptive text . .for example Account Name: John Doe Balance: $ 100 1.2b Test the new accountlnfo function by modifying the main function code in main.coD. Replace the individual calls to the getName and getBalance functions with a call to accountlnfo

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!