Define a class named Money that stores a monetary amount. The class should have two private integer variables, one to store the number of dollars and another to store number of cents. Create a default constructor that sets the monetary amount to 0 dollars and 0 cents , create a second constructor with input parameters for the of the dollars variables and third copy constructor. Add accessor and mutator functions to read and set both variables .Add another function that returns the monetary amount as double . Write program that tests all your constructors and functions for at least three different Money objects
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Define a class named Money that stores a monetary amount. The class should have two private integer variables, one to store the number of dollars and another to store number of cents. Create a default constructor that sets the monetary amount to 0 dollars and 0 cents , create a second constructor with input parameters for the of the dollars variables and third copy constructor. Add accessor and mutator functions to read and set both variables .Add another function that returns the monetary amount as double . Write program that tests all your constructors and functions for at least three different Money objects
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images