Page 1 of 1

// Program Money manipulates instances of class Money #include using namespace std; class Money{ public: void

Posted: Sat May 14, 2022 7:01 pm
by answerhappygod
// Program Money manipulates instances of class Money
#include <iostream>
using namespace std;
class Money{
public:
void Initialize(long, long);
long DollarsAre() const;
long CentsAre() const;
Money AddMoney();
private:
long dollars;
long cents;
};
int main(){
Money money1;
Money money2;
Money money3;
money1.Initialize(10, 59);
money2.initialize(20, 70);
money3=money1,Add(money2);
cout<< “$”<<money3.DollarsAre() << “.”
<< money3.CentsAre() <<endl;
return 0;
}
//****************************************************//
void Money::Initialize(long newDollars, long newCents){
//Post: dollars is set to NewDollars, cent is set to
NewCents
dollars= newDollars;
cents= newCents;
}
PART A:
- Complete the code for the member functions: DollarsAre(),
CentsAre(), AddMoney() and run the program.
- Return completed program and screen shot of program execution
(with data provided in the program an (0, 60), (100, 10)
Take the program Money and re-organize it into 3 files: Money.h,
Money.cpp, UseMoney.cpp.
UseMoney.cpp is the client program. Run the program UseMoney,
the results should be the same.
PART B:
-Research how to read data from a file in C++ and create a file
Moneyfile.txt with 20 data items corresponding to the Money
class.
- Implement the code for the Unsorted Data Structure and the
Sorted Data Structure seen in class.
- Create two data structure: UMoney for an Unsorted list and
SMoney for the Sorted List, Write the code to read from
Moneyfile.txt and store in UMoney. Using the list UMoney, put its
items in the list SMoney.
- Implement the code for UnsortedLinked list.
- Create a Data structure LMoney and using the list UMoney, put
its elements in LMoney