C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed
10th Edition
ISBN: 9780134448848
Author: Paul Deitel, Harvey Deitel
Publisher: PEARSON
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
Fix an error and show it please? And here are the information about the homework and for the error too. def kwargs_to_args_decorator(*args, **kwargs): This question is meant to test your knowledge of creating a decorator that accepts an arbitrary number of positional and keyword arguments, to decorate a function that accepts an arbitrary number of positional and keyword arguments, and alters the arguments before passing them to the decorated function. When the decorated function is invoked, this decorator should modify the arguments the decorated function receives. This decorator should filter out all positional arguments passed to the decorated function, which are found in the positional arguments passed to the decorator when the decorator was initialized. It should also filter out all keyword arguments with keys that are found in the keyword arguments given to the decorator when the decorator was initialized. After performing the modifications to the arguments, the decorator should…
Please fill in the blanks for the following statements: The class function with no return type that is used to initialize data members is called the __________________________.
Construct.

Chapter 5 Solutions

C++ How To Program (Early Objects Version), Global Edition, With Access Card, 10 Ed

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