Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 12, Problem 3P
Program Plan Intro

“Money” ADT Class

Program plan:

  • For file “MoneyADT.h”:
    • Include required header file.
    • Define a class for “Money”.
      • Declare the function for overload operator “<”, “<=”, “>’, “>=”, “+”, “-” and “==”.
      • Declare the constructor for “Money” class.
      • Declare the function for compute total amount, total dollars and total cents.
      • Declare the function for operator “>>” and “<<”.
      • Declare required variables.
  • For file “MoneyADT.cpp”:
    • Define function for overload operator “<”, “<=”, “>” and “>=”.
    • Define function for “percent”.
      • This function is used to compute the percentage amount for given money.
    • Define function for arithmetic operator “+” and “-” with two arguments.
    • Define function for overload operator “==”.
    • Define function for overload operator “-” with one parameter.
    • Define default constructor for “Money” class, constructor with one argument and two arguments.
    • Define function “computeTotalAmount”.
      • This function is used to compute the total amount.
    • Define function “computeTotalDollars”.
      • This function is used to compute the dollars in given amount.
    • Define function “computeTotalCents”.
      • This function is used to compute the cents in given amount.
    • Define function “forDollarConversion” which is used to convert amount to dollar
    • Define function “forCentsConversion” which is used to convert the amount to cents.
    • Define function “forRoundedValue” which is used for convert the result in rounded value.
    • Define function for input and output operator.
  • For file “main.cpp”:
    • Include required header file.
    • Create an object for “Money” class.
    • Create an object for “Money” class with argument.
    • Declare variable for file input and file output.
    • Open the given input file.
    • Check the given file is found or not using “if” loop.
    • Read the amount from file.
    • Display the purse amount.
    • Compare the given amount and purse amount.
    • Compute sum of amount and purse and display it.
    • Compute the difference of two amount and display it.
    • Check the amount using the comparison operator “>=”.
    • Check the amount using the comparison operator “>”.
    • Check the amount using the comparison operator “<=”.
    • Check the amount using the comparison operator “<”.
    • Finally close input and output file.

Blurred answer
Students have asked these similar questions
Hey there I am struggling with creating a second class module in PYTHON - that would import an already existing class I have finished from another module file called LANDINGSPOT,  the class I am struggling with follows the exact order below*        - class PLANE    first-class which is done (Landingspot CLASS with objects       ID, city, country )   and am trying to create another class module PLANE.     (flightNumber, Start, goingTo).   Each class would be eventually reading from text files with some spaces and commas separating randomly that’s where they would be getting data but that's for another module, which would need to import PLANE class.   'As suggested by its name, this class represents a 'Plane' from one landingSpot to another landingSpot in the program. Each Plane object must have a flightNumber (the unique 6-character code containing 3 letters followed by 3 digits), Start place, and a goingTo. Both the Start and goingTo must be LandingSpot objects within the…
Develop a program (or find one on the internet) to exemplify and document dynamic binding). A parent and two or more child classes are needed. Shape, Triangle, Rectangle are common examples where Shape is the parent and Triangle and Rectangle are the child classes. Create a project for the program, add the parent and childs classes to it. Use main to exemplify dynamic binding by creating an array or ArrayList of the parent class type and filling it with objects of the child class types. Loop through the array and display all the objects in it by calling their toString method. Then create a method whose parameter is the parent class type. Have main call the method sending it the child types. What the method does is up to you. Heavily document this program since this is not a prescribed assignment. I want to read your words. So I want you telling me what it does, how it does it, and how it has anything to do with dynamic binding. Then using screen capture software, take…
IN JAVA, DO THESE INTERFACES IN POINT AND LINE CLASSES
Knowledge Booster
Background pattern image
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