Write a procedure to add and subtract-money, C/C++ Programming

Money is immutable and is associated with a currency. When two money entities are added or subtracted be sure to consider currency conversion. You must create a money object resulting from the addition or subtraction which has the same currency as the first money entity passed to the add-money or subtract-money procedure.

(a) You are required to write the procedures: add-money and subtract-money. The procedures add-money and subtract-money have 2 arguments, both being Money.

(b) You are required to write the procedures: multiply-money and divide-money. The multiply-money and divide-money have 2 arguments, the first of which is Money, the second of which is a number.

(c) You must also write a make-money procedure, which has 2 arguments, the amount as a number and a currency, which is a symbol.

(d) Write accessor procedures for the amount and currency parts of a Money object.

(e) Write a money-as procedure. This procedure has 2 arguments, the first of which is Money, the second of which is a currency symbol. The procedure returns a new Money object of the currency requested.

(f) You must also implement a currency procedure which has a symbol argument, c, that returns the currency conversion value for that currency. Assume that 'dollars, 'pounds, and 'euros are valid currencies. The currency procedure returns #f for all other currencies. The conversion value for 'dollars should be 1.0, 0.636 for 'pounds and 0.756 for 'euros. An example is shown below:

(define dollar-amount (make-money 100 'dollars)) ; Make a $100
(define pound-amount (make-money 100 'pounds)) ; Make 100 pounds
(define dollars-plus-pounds (add-money dollar-amount pound-amount)) ; Result should be dollars
(define pounds-plus-dollars (subtract-money pound-amount dollar-amount)) ; Result should be pounds
(currency 'euros) ; Result should be 0.756

 

Posted Date: 3/25/2013 1:04:29 AM | Location : United States







Related Discussions:- Write a procedure to add and subtract-money, Assignment Help, Ask Question on Write a procedure to add and subtract-money, Get Answer, Expert's Help, Write a procedure to add and subtract-money Discussions

Write discussion on Write a procedure to add and subtract-money
Your posts are moderated
Related Questions
Project Description: Project is related indexing data related some data structure. I need to share all information related project later if i contact any body Skills required


How to define a derived class ? A singly inherited derived class id defined by writing : The keyword class. The name of the derived class . A single colon (:).

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

I need to create a connection to FIFA Ultimate Team 14, I want to utilize C++ specifically for the reason that that is the language I have the most experience in. There are a co

Constructor and Destructor function with derived classes If there are constructors included in the base class and the derived class, the compiler automatically calls both of th

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''''a''''-''''z'''') and

Write a program to find minimum number of shelves

Describe what is actual arguments? - When certain functions are created and used to perform an action on some provided values, some values are required to be passed to them. Th

External Variables Different functions of the similar program can be written in different source files and can be compiled together. The scope of a global variable is not limit