Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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
Chapter 12 Solutions
Problem Solving with C++ (10th Edition)
Ch. 12.1 - Suppose that you are defining an ADT class and...Ch. 12.1 - Which of the following files has a name that ends...Ch. 12.1 - Prob. 3STECh. 12.1 - Suppose you define a class in separate files and...Ch. 12.1 - Suppose you want to change the implementation of...Ch. 12.1 - What is the difference between an ADT you define...Ch. 12.2 - Consider the program shown in Display 12.5. Could...Ch. 12.2 - In Self-Test Exercise 7, we saw that you could not...Ch. 12.2 - Prob. 9STECh. 12.2 - Prob. 10STE
Ch. 12.2 - Consider the following function declarations from...Ch. 12.2 - Would the program in Display 12.8 behave any...Ch. 12.2 - Prob. 13STECh. 12.2 - In Display 12.7 there are two groupings for the...Ch. 12 - Add the following member function to the ADT class...Ch. 12 - Prob. 3PCh. 12 - Redo Practice Programs 2 from Chapter 11, but this...Ch. 12 - This Practice Program explores how the unnamed...Ch. 12 - Prob. 1PPCh. 12 - Redo (or do for the first time) Programming...Ch. 12 - Prob. 3PP
Knowledge Booster
Similar questions
- Your assignment for this course is to implement a beginner level Book Management System (BMS) in Java language. BMS contains 2 classes: Bookand BookList. The Book class has the following attributes: code: a String object, that hold the book’s code. title: a String object, that hold the book’s title. qua: int variable, that hold the number of books with the same code in the library. price: a double variable, that hold the book’s price. The BookList class contains only one data member: ArrayList<Book> t. When running the program display the menu as below:1. Input & add book(s) to the end.2. Display all books.3. Search a book for given code.4. Update the book’s price for given code.5. Find the (first) max price value.6. Sort the list ascendingly by code.7. Remove the book having given code.8. Load data from file.0. Exit.Notes:(1) The book’s code must be unique in the list.(2) Display all books in format (code, title, quantity, price).(5)…arrow_forwardHey there I am struggle with importing a existing class in PYTHON in the order below for class PLANE (Landingspot CLASS with objects ID, city, country )and am trying to import to another class module PLANE(flightNumber, Start, goingTo). Each class would be eventually reading from text files with some spaces and commas separating randomly. '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 program.' Landingspot Ex textfile contains JFK,UnitedStates, NewYork PHL,UnitedStates,Philadelphia etc Class Plane EX text file contains KPP582,YYZ,ICN VDT680,JRS,PHL XPA230,YEG,ORD XGY802, YUL,GIG JHW048,ORD,NBO KGM892,SYD,JRS XUC141,JFK, DEN RIN900,FCO,PEK EKR896,SFO, YHZ First class I have…arrow_forwardIn c++ Create a new project named lab11_1. You will be implementing three classes: A Clothing class, a Shirt class, derived from Clothing and third class of your choice that will be derived from Clothing. I have included the UML diagrams for Clothing and Shirt. You will need to make sure that the class you derive from Clothing is appropriate, meaning it makes sense that it would inherit from Clothing. In your driver file, I’d like to see a Shirt object created, as well as an object of the class type that you create. Set the class variable members to specific values, and then print. You can choose to override the output operator to make this easier, or you can implement a method named print(). Create a new project named lab11_2. Come up with your own base class, and derived class. No big specifications here on what you need to do (in terms of overloading operators, friend functions, static variables, composition, etc), but you have to make use of the base class members in the derived…arrow_forward
- Create the class DynamicArrayOfStrings that implements the following two interfacesarrow_forwardplease answer with outputarrow_forwardWhich of these statements IS NOT true regarding design by contract. Question options: Creating and implementing an interface is an example of implicit design by contract. Explicit design by contract makes specifications part of the compiled code for a program. Creating and building from an abstract class is an example of explicit design by contract. When we code to an interface, we create a set of methods to be used to interact with a class; these methods establish a contract for how the design should work. Option B is not the correct answer.arrow_forward
- Put the client program in a separate file from the class, and divide the class into specification file (fraction.h) and implementation file (fraction.cpp), so your code will be in 3 separate files. Fraction.h #include <iostream>using namespace std; int gcd(int a, int b) { if (a == 0) return b; if (b == 0) return a; if (a == b) return a; if (a > b) return gcd(a - b, b); return gcd(a, b - a);} class Fraction {private: // numerator and denominator int n, d; public: // simplifies the fraction void simplify() { int g = gcd(n, d); n /= g; d /= g; } // default constructor Fraction() { n = 0, d = 1; } // parameterised constructor Fraction(int a, int b) { n = a, d = b; simplify(); } // prints the fration as n/d void print() const { cout << n << "/" << d; } // multiplies 2 fractions and returns it Fraction multipliedBy(Fraction f) const { f.simplify(); Fraction r; r.n = n * f.n; r.d = d * f.d; r.simplify(); return r; } // divides two fraction and…arrow_forwardPrepare a mini project of an Ice cream truck. Using basic OOP concepts like Inheritence, polymorphism, and files. Ice cream truck should have different flavours and other sauces or waffles with varying prices. And a function to calculate the total bill and to display it.arrow_forwardThis discussion assignment examines variable scope. For this assignment, we will be examining the Beverage2 class (an updated version of the Beverage class from discussion 1), its subclass Espresso, and the TestBeverage2 class. This time, assume that all source files are in the same package. Note that some lines may wrap, but are still considered on one line. Examine the code below. Recall that variables have four kinds of scope: static, instance, local, and block. For each variable listed below, identify its scope (static, instance, local, or block) and describe the scope using complete sentences. An example description is provided, after the code listing, for the ounces variable in the Beverage2 class. Please describe the scope for the following variables: The num variable in the Beverage2 class The price variable in the Beverage2 class The shots variable in the Espresso class The b variable in the TestBeverage2 class The j variable in the TestBeverage2 class public abstract…arrow_forward
- 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.arrow_forwardC++ programming language Images attached are the task and targeted output. I was asked to modify "DynamicStringArray.cpp" file to make the program output the correct output. PLEASE i only have to modify the " DynamicStringArray.cpp" code to make the program right. Please help me. BELOW ARE THE PROVIDED CODES IN ORDER TO COMPLETE IT: DynamicStringArray.cpp: // Write the implementation of every method of the class// DynamicStringArray defined in DynamicStringArray.h#include "DynamicStringArray.h"//default constructorDynamicStringArray ::DynamicStringArray (){//write code body of DynamicStringArray ()}int DynamicStringArray ::sizeIs(){//write code body of sizeIs ()}void DynamicStringArray ::addEntry (string str){//write code body of addEntry ()};bool DynamicStringArray::deleteEntry (string str){//write code body of deleteEntry ()}string* DynamicStringArray::getEntry(int index){//write code body of deleteEntry ()}//destructorDynamicStringArray ::~DynamicStringArray (){//write code body of…arrow_forwardC++ programming language Images attached are the task and targeted output. I was asked to modify "DynamicStringArray.cpp" file to make the program output the correct output. PLEASE i only have to modify the " DynamicStringArray.cpp" code to make the program right. Please help me. BELOW ARE THE PROVIDED CODES IN ORDER TO COMPLETE IT: DynamicStringArray.cpp: // Write the implementation of every method of the class// DynamicStringArray defined in DynamicStringArray.h#include "DynamicStringArray .h"//default constructorDynamicStringArray ::DynamicStringArray (){//write code body of DynamicStringArray ()}int DynamicStringArray ::sizeIs(){//write code body of sizeIs ()}void DynamicStringArray ::addEntry (string str){//write code body of addEntry ()};bool DynamicStringArray::deleteEntry (string str){//write code body of deleteEntry ()}string* DynamicStringArray::getEntry(int index){//write code body of deleteEntry ()}//destructorDynamicStringArray ::~DynamicStringArray (){//write code body…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education