Write a checkbook balancing program. The program will read in the following information for all checks that were not cashed as of the last time the user balanced their checkbook: the number of each check the amount of the check whether or not the check has yet been cashed Use a dynamic array with a class base type for the checks. The checkclass should have three member variables: check number check amount whether or not the check's been cashed And don't forget to provide accessors, mutators, and constructors as well as input and output methods. Also if any library definitions are used, please show them. Here is the money class definition that should be used: // This is the HEADER FILE money.h. This is the INTERFACE for the class // Money. Values of this type are amounts of money in U.S. currency. #ifndef MONEY_H #define MONEY_H #include class Money { long all_cents; // monetary value stored as pennies public: // Initializes the object to $0.00. Money(void); // Initializes the object to dollars*100 cents. Money(long dollars); // Initializes the object to dollars*100 + cents. Money(long dollars, short cents); // Postcondition: return value is sum of calling object and amount. // neither amount nor calling object are changed. Money add(const Money & amount) const; // Postcondition: return value is difference of calling object and amount. // neither amount nor calling object are changed. Money subtract(const Money & amount) const; // Postcondition: return value is arithmetic negation of calling object. // calling object is not changed. Money negate(void) const; // Returns true if the calling object equals the amount, false otherwise. bool equals(const Money & amount) const; // Returns true if the calling object is less than the amount, // false otherwise. bool less(const Money & amount) const; // Postcondition: calling object's value is read from the stream // in normal U.S. format: $ddd.cc. void input(std::istream & ins); // Postcondition: calling object's value is printed on the stream // in normal U.S. format: $ddd.cc. (calling object // is not changed) void output(std::ostream & outs) const; // Returns amount of money in decimal format. double get_value(void) const; }; #endif
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:
Write a checkbook balancing program. The program will read in the following information for all checks that were not cashed as of the last time the user balanced their checkbook:
-
the number of each check
-
the amount of the check
-
whether or not the check has yet been cashed
Use a dynamic array with a class base type for the checks.
The checkclass should have three member variables:
-
check number
-
check amount
-
whether or not the check's been cashed
And don't forget to provide accessors, mutators, and constructors as well as input and output methods. Also if any library definitions are used, please show them.
Here is the money class definition that should be used:
// This is the HEADER FILE money.h. This is the INTERFACE for the class
// Money. Values of this type are amounts of money in U.S. currency.
#ifndef MONEY_H
#define MONEY_H
#include <iostream>
class Money
{
long all_cents;
// monetary value stored as pennies
public:
// Initializes the object to $0.00.
Money(void);
// Initializes the object to dollars*100 cents.
Money(long dollars); // Initializes the object to dollars*100 + cents.
Money(long dollars, short cents);
// Postcondition: return value is sum of calling object and amount. // neither amount nor calling object are changed.
Money add(const Money & amount) const;
// Postcondition: return value is difference of calling object and amount. // neither amount nor calling object are changed.
Money subtract(const Money & amount) const;
// Postcondition: return value is arithmetic negation of calling object. // calling object is not changed.
Money negate(void) const;
// Returns true if the calling object equals the amount, false otherwise.
bool equals(const Money & amount) const;
// Returns true if the calling object is less than the amount, // false otherwise.
bool less(const Money & amount) const;
// Postcondition: calling object's value is read from the stream // in normal U.S. format: $ddd.cc.
void input(std::istream & ins);
// Postcondition: calling object's value is printed on the stream // in normal U.S. format: $ddd.cc. (calling object // is not changed)
void output(std::ostream & outs) const;
// Returns amount of money in decimal format.
double get_value(void) const;
};
#endif
Trending now
This is a popular solution!
Step by step
Solved in 2 steps