Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This question has been posted before and I am looking for the currency.cpp and currency.h to go along with the answer posted A. Create a

This question has been posted before and I am looking for the currency.cpp and currency.h to go along with the answer posted

A. Create a currency class with four attributes - currency name, whole parts and fractional parts and fractional's name such that 100 fractional parts equal 1 whole part.

B. Create 5 derived classes for the following currencies - Dollar, Euro, Yen, Rupee, and Yuan. I know this program can be done without inheritance but it is a requirement for this lab. You will be adding and subtracting currency values using the form: Dollar, 1, 25, cent Euro, 3, 33, cent Yen, 100, 54, sen Rupee, 7, 11, paise Yuan, 50, 86, fen

C. Define 2 overloaded operators to add or subtract different currency objects - care should be taken that you can only perform these operations on objects of the same currency. Also, take care that fractional parts roll into whole parts.

D. Define an overloaded input stream operator to accept values of any currency as well as an overloaded output stream operator to write out the value of the currency.

E. When initializing currency objects, your code should demonstrate polymorphic construction. Your constructors should also use initialization lists.

F. Now, define a Wallet class that will contain the 5 individual currency types above and will implement the following - number of individual currency types whose value is non-zero, check if a currency type exists with non-zero value in the wallet, add money by currency type, remove money by currency type, zero out all currency types, check if wallet is empty. What this means is that your wallet can only contain one object of each currency type. To add or remove money into/from wallet, check if currency has a non-zero value in the wallet. If so, add or remove the amount specified.

G. Your main should allow the user to add a maximum of 5 different currency types to the wallet in the form of the base currency array - this will help you demonstrate the polymorphic construction. Demonstrate the overloaded subscript operator for the Wallet class. The user should be able to add or remove as many currency values for any of the five currency types. The user should also be able to output the total value by name of the currencies in the wallet. Finally, they should be able to empty the wallet and print relevant information about the operation. User Interactivity is extremely important - give due consideration to it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

Write the difference between sexual and asexual reproduction.

Answered: 1 week ago

Question

What your favourite topic in mathematics?

Answered: 1 week ago

Question

Briefly describe vegetative reproduction in plants.

Answered: 1 week ago