Question: Carefully examine the code in Program 13-15, Implementing the Class, in Section 13.13, Focus on Problem Solving and Program Design: An OOP Case Study, in

Carefully examine the code in Program 13-15, "Implementing the Class," in Section 13.13, "Focus on Problem Solving and Program Design: An OOP Case Study," in Ch. 13, "Introduction to Classes," of Starting Out With C++ From Control Structures Through Objects. Answer the following four questions in a Microsoft Word document:

On what line number(s) is the Account class instantiated?

Is the Account class declared in the code in Program 13-15? If not, where is the Account class declared and how do you know this?

On what line number(s) is the Account class constructor called?

On what line numbers are Account member functions called?

// This program demonstrates the Account class. #include #include #include #include "Account.h" using namespace std;

// Function prototypes void displayMenu(); void makeDeposit(Account &); void withdraw(Account &);

int main() { Account savings; // Savings account object char choice; // Menu selection

// Set numeric output formatting. cout << fixed << showpoint << setprecision(2);

do { // Display the menu and get a valid selection. displayMenu(); cin >> choice; while (toupper(choice) < 'A' || toupper(choice) > 'G') { cout << "Please make a choice in the range " << "of A through G:"; cin >> choice; } // Process the user's menu selection. switch(choice) { case 'a': case 'A': cout << "The current balance is $"; cout << savings.getBalance() << endl; break; case 'b': case 'B': cout << "There have been "; cout << savings.getTransactions() << " transactions. "; break; case 'c': case 'C': cout << "Interest earned for this period: $"; cout << savings.getInterest() << endl; break; case 'd': case 'D': makeDeposit(savings); break; case 'e': case 'E': withdraw(savings); break; case 'f': case 'F': savings.calcInterest(); cout << "Interest added. "; } } while (toupper(choice) != 'G');

return 0; }

//**************************************************** // Definition of function displayMenu. This function * // displays the user's menu on the screen. * //****************************************************

void displayMenu() { cout << " MENU "; cout << "----------------------------------------- "; cout << "A) Display the account balance "; cout << "B) Display the number of transactions "; cout << "C) Display interest earned for this period "; cout << "D) Make a deposit "; cout << "E) Make a withdrawal "; cout << "F) Add interest for this period "; cout << "G) Exit the program "; cout << "Enter your choice: "; }

//************************************************************* // Definition of function makeDeposit. This function accepts * // a reference to an Account object. The user is prompted for * // the dollar amount of the deposit, and the makeDeposit * // member of the Account object is then called. * //*************************************************************

void makeDeposit(Account &acnt) { double dollars;

cout << "Enter the amount of the deposit: "; cin >> dollars; cin.ignore(); acnt.makeDeposit(dollars); }

//************************************************************* // Definition of function withdraw. This function accepts * // a reference to an Account object. The user is prompted for * // the dollar amount of the withdrawal, and the withdraw * // member of the Account object is then called. * //*************************************************************

void withdraw(Account &acnt) { double dollars;

cout << "Enter the amount of the withdrawal: "; cin >> dollars; cin.ignore(); if (!acnt.withdraw(dollars)) cout << "ERROR: Withdrawal amount too large. "; }

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!