Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ >3.13 (Removing Duplicated Code in the main Function) In Fig. 3.9, the main function contains six statements (lines 1415, 1617, 2627, 2829, 3738 and

c++
image text in transcribed
>3.13 (Removing Duplicated Code in the main Function) In Fig. 3.9, the main function contains six statements (lines 1415, 1617, 2627, 2829, 3738 and 39-40) that each display an Account object's name and balance. Study these statements and you'll notice that they differ only in the AC- count object being manipulated-account or account2. In this exercise, you'll define a new dis- playAccount function that contains one copy of that output statement. The member function's parameter will be an Account object and the member function will output the object's name and bal- ance. You'll then replace the six duplicated statements in main with calls to displayAccount, passing as an argument the specific Account object to output. Modify Fig. 3.9 to define the following displayAccount function after the using directive and before main: void displayAccount (Account account ToDisplay) { // place the statement that displays // accountToDisplay's name and balance here Replace the comment in the member function's body with a statement that displays accountToDis- play's name and balance. Once you've completed displayAccount's declaration, modify main to replace the statements that display cach Account's name and balance with calls to displayAccount of the form: displayAccount (nameOfAccountObject); In each call, the argument should be the account1 or account object, as appropriate. Then, test the updated program to ensure that it produces the same output as shown in Fig. 3.9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions