Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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
Make a data type called Version that reflects the version number of a piece of software, like 115.1.1, 115.10.1, or 115.10.2. Implement the Comparable interface to make 115.1.1 less than 115.10.1, 115.1.1 less than 115.10.1, etc.
Write a program in the Java language requires the management of university students, where student data (name, student number, and specialization) are saved, and then he can add and delete study materials for the current semester, and you can also add the grade for each subject (with the addition of the final code for the degree automatically).Note: The class principle is used to solve this assignment.
only in java not in java c++   Create an interface EnhancedShape that extends Shape and also requires a method public double perimeter( ) to be implemented by any class that uses the interface. Create a class file, an interface ehancedshape extends shape, and an interface shape file.
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