C++ How to Program (10th Edition)
C++ How to Program (10th Edition)
10th Edition
ISBN: 9780134448237
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 3, Problem 3.13E

(Removing Duplicated Code in the main Function) In Fig. 3.9, the main function contains six statements (lines 14-15, 16-17, 26-27, 28-29, 37-38 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 Account object being manipulated-accountl or account2. In this exercise, you'll define a new displayAccount 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 balance. 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 accountToDisplay) {

// 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 accountToDisplay’s name and balance.

  Once you've completed displayAccount’s declaration, modify main to replace the statements that display each Account’s name and balance with calls to displayAccount of the form:

  displayAccount(nameOfAccountObject);

In each call, the argument should be the account1 or account2 object, as appropriate. Then, test the updated program to ensure that it produces the same output as shown in Fig. 3.9.

Blurred answer
Students have asked these similar questions
1. [LO 1, LO 2, LO 3 & LO 4, Treasure Hunter Description You are in front of a cave that has treasures. The cave can be represented in a grid which has rows numbered from 1 to , and columns numbered from 1 to . For this problem, define (x,y ) as a tile that is in the the-x row and the y-row. There is a character in each tile, which indicates the type of that tile. Tiles can be floors, walls, or treasures which are represented respectively by the characters '.' (period), '#' (hashmark), and '*' (asterisk). You can go through the floor tiles and treasures, but you can't get past the wall tiles.Initially, you are in a tile (??, Sy). You want to visit all the treasure squares, and retrieve the treasure. When you visit a treasure tile, the treasure is instantly retrieved, and the tile turns into a floor.In a move, if you are on a tile (?,y), then you can move to the right tile above (?-1,y), right (?,y + 1), down (? + 1, ), and left (?, 1) of the current tile. The tile you visit must…
HCI is (Human Computer Interaction) Answer the following five statements by first stating whether it is true or false and then given one sentence for justifying your answer a) You drag a folder to make a copy of its contents. An animation appears on the screen, showing files moving from one folder to another. This is an example of feedback. b) In augmented reality a screen is composed of a computer animation of the reality. c) The Model Human Processor is used in HCI to model complex cognitive processes d) Petri Nets can be helpful in modeling concurrent activities in a user interface. e) Gestalt is important to HCI as it offers tools to understand scenes.
How is the body of a for loop defined? A. The body of a for loop is defined by an indented block of code following the for statement, similar to the body of an if statement. B. The body of a for loop is defined by an opening curly brace, one or more lines of code and a closing curly brace. C. The body of a for loop is defined by a left parenthesis, one or more lines of code and a right parenthesis. D. For loops do not have a body. What is a for loop? A. The for loop is the new improved three loop as it was defined in Python version 2. B. The for loop enables a program to repeat a block of code multiple times. C. The for loop enables a program to repeat a block of code one time, much like the if statement. D. The for loop is a block of code included at the beginning (the for) of a program.   Which of the following is an example of a sequence that might be used in a for statement? A. An integer B. A floating point number C. A list D. A boolean variable   How is a…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License