C++ How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (10th Edition)
Question
Book Icon
Chapter 5, Problem 5.32E
Program Plan Intro

Program Plan:

1. Include Header files.
2. Declare class DollarAmount.

  • Start declaring public member functions.
  • Declare “DollarAmount(int64_t value)” constructor which puts pennies in variable “amount”.
  • Declare “DollarAmount(int64_t value1, int64_t value2)” constructor which takes two arguments to take value in dollars and cents. These are then converted to pennies and transferred to variable “amount”.
  • Define function add to add amount to variable “amount”.
  • Define function to subtract an amount from variable “amount”.
  • Define member function "divide" to divide "amount" with an argument "d" passed in the function using rounding technique used in addInterest member function.
  • Define function addInterest to calculate interest on variable “amount”.
  • Use conditional operator to pass value to constructor of class, calculating value using Banker’s rounding.
  • Define function "toString()" to return a string representation of a DollarAmount object for display purpose.
  • Declare private members:
  • amount to store dollar amount in pennies.

3. End of class.
4. Start the main function
  • Declare two objects of class DollarAmount "d1" and "d2" by passing amount in pennies, which will invoke single argument constructor;
  • Display result of adding amount of d2 to d1 using "add" function modifying object d1.
  • Display result of subtracting amount of d2 from d1 using "subtract" function modifying object d1.
  • Display result of subtracting amount of d1 from d2 using "subtract" function modifying object d2.
  • Ask for the interest rate and divisor in "rate" and "divisor".
  • Create object "balance" of class DollarAmount with initial balance 100000.
  • Display initial balance of "balance" object.
  • Display headers of the table as "Interest Year Amount on deposit"
  • Use for loop to run for 10 years
  • Call function addInterest using "balance" object, with "rate" and "divisor"
  • Display values of Interest Year and balance amount
  • End of for loop
  • End of main function

Blurred answer
Students have asked these similar questions
Can you find an example order DFS explores the vertices in the graph included assuming DFS starts at vertex 4. The adjacency lists are in ascending order by the numeric label of the vertices.
Please original work What is differences between big data and data warehousing, which one is better for analytics, why it is better, and what would you think an example of when it would be a better choice. Please cite in text references and weblinks
Identify the most applicable web analytics that a B2C (business to consumer) company should be monitoring at its website. Describe three or more metrics, provide a description of each, and explain why you believe they are important?

Chapter 5 Solutions

C++ How To Program Plus Mylab Programming With Pearson Etext -- Access Card Package (10th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning