Question: Account.h #include class Account { public: // member functions accessible by anyone Account(std::string, int); Account(); void deposit(int); void withdraw(int); int getBalance() const; void setName(std::string); std::string

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

Account.h

#include  class Account { public: // member functions accessible by anyone Account(std::string, int); Account(); void deposit(int); void withdraw(int); int getBalance() const; void setName(std::string); std::string getName() const; void accountInfo() const; private: // data members only accessible by member functions // (and "friend" functions/classes) std::string name; int balance{0}; // default initial value }; 

Account.cpp

#include  #include "Account.h" Account::Account(std::string accountName, int startingBalance) : name{accountName} // member initializer list { if (startingBalance > 0){ balance = startingBalance; } } // default constructor Account::Account() {} // function to add to balance void Account::deposit(int depositAmount){ if (depositAmount > 0){ balance += depositAmount; } } // function to reduce balance void Account::withdraw(int withdrawAmount){ if (withdrawAmount > 0){ if (withdrawAmount  

main.cpp

#include  #include  #include "Account.h" using namespace std; int main() { Account accountA("John Doe", 100); Account accountB("Jane Doe", -100); //Account accountA; //Account accountB; // display initial information accountA.accountInfo(); accountB.accountInfo(); int depositAmt; cout > depositAmt; accountA.deposit(depositAmt); // use member function cout > depositAmt; accountB.deposit(depositAmt); // use member function // display updated information accountA.accountInfo(); accountB.accountInfo(); int withdrawAmount; cout > withdrawAmount; accountA.withdraw(withdrawAmount); // use member function cout > withdrawAmount; accountB.withdraw(withdrawAmount); // use member function // display updated information accountA.accountInfo(); accountB.accountInfo(); } 
CSCI 272-Spring 2019 Lab 2- Classes and Streams - 15 pts Start with the Account.h, Account.cpp and main.cpp files modified in class. 2.la Add data validation to all input of integers in main.cpp. If the user enters a character instead of an integer value, clear the failed input stream and ignore the rest of the characters in the input stream. Reprompt the user to enter an integer. 2.1b Test your validation code by entering characters instead of numbers when prompted fora deposit or withdrawal amount. You should be reprompted to enter an amount. 2.2a Add an accountStatement function to the Account class that will print the name of the account and all the stored transactions in order. Next to each transaction, include a text label that indicates whether it is a deposit or a withdrawal transaction. 2.2b Test your accountStatement function after creating several deposit and withdraw transactions for the account

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!