A. Update the Fraction class given in the Lecture notes or as discussed in class meetings as follows,

1. Add your FIRST NAME and the initial of your last name to the name Fraction and use this as your updated class. For examples, if your first name is John Smith then update the class name to be FractionJohnS.

2. Add and update all class constructors for your Fraction class to handle the initialization appropriately.

There must be as least 2 constructors of
(i) Default; and
(ii) Copy.

Each constructor should print the confirmation (e.g., "Calling Fraction()", or Calling Fraction(const Fraction&)).

3. Provide a destructor with a confirmation when removing the object (i.e., "Calling ~Fraction()").

4. Provide get/set member functions for each private member data.

5. A member function print() that will print the current Fraction object.

B. Provide the following member functions,

  • A function add() to add a Fraction object; and
  • A function subtract() to subtract a Fraction object; and
  • A function multiply() to multiply a Fraction object; and
  • A function divide() to divide a Fraction object; and

C. Provide the following member operator functions,

  • A function operator=() to assign a Fraction object.
  • A function operator+() to add a Fraction object; and
  • A function operator-() to subtract a Fraction object; and
  • A function operator*() to multiply a Fraction object; and
  • A function operator/() to divide a Fraction object; and

D. Provide the following stand-alone functions,

  • A function init() to set up or update the 2 required Fraction objects.
  • A function add() to add 2 Fraction objects; and
  • A function subtract() to subtract 2 Fraction objects; and
  • A function multiply() to multiply 2 Fraction objects; and
  • A function divide() to divide 2 Fraction objects; and
  • A function print() to print the required Fraction objects; and
  • An appropriate menu() function to produce the required output as displayed below.

C. Run a driver named as cis25Spring2018YourNameHw4Ex1.cpp and record the output of the program.

(a) The output screen should have the following lines displayed before any other display or input can be seen,

CIS 25 – C++ Programming
Laney College
Your Name

Assignment Information --
Assignment Number: Homework 04,
Exercise #1
Written by: Your Name
Due Date: Due Date

(b) Then, the output screen should be followed by a sample output as follows,

*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 7
Printing Option --
Not a proper call as no Fractions are available!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 2
Adding Option --
Not a proper call as no Fractions are available!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 1
INITIALIZING Option –
Calling menuInit()!
**************************
* SubMENU – INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 2
Not a proper call as no Fractions are available!
(How many objects were involved? XXX)
**************************
* SubMENU – INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 5
WRONG OPTION!
(How many objects were involved? XXX)
**************************
* SubMENU – INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 1
Creating 2 NEW Fraction objects –-
Calling create()!
Creating Left Fraction
Enter num: 5
Enter denom: -9
Left Fraction –
num: -5
denom: 9
Creating Rigft Fraction
Enter num: 3
Enter denom: -4
Right Fraction –
num: -3
denom: 4
(How many objects were involved? XXX)
**************************
* SubMENU – INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 2
Updating 2 EXISTING Fraction objects –-
Calling updatingMenu()!
******************************
* SubMENU – UPDATING *
* 1. Left Fraction *
* 2. Right Fraction *
* 3. Left & Right Fractions *
* 4. Returning *
******************************
Select an option (integer only): 2
Updating LEFT Fraction –
Enter num: 15
Enter denom: -11
(How many objects were involved? XXX)
******************************
* SubMENU – UPDATING *
* 1. Left Fraction *
* 2. Right Fraction *
* 3. Left & Right Fractions *
* 4. Returning *
******************************
Select an option (integer only): 4
Returning to previous menu!
(How many objects were involved? XXX)
**************************
* SubMENU – INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 3
Returning to previous menu!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 6
PRINTING Option –
Calling menuPrint()!
********************************
* Sub Menu -- PRINTING *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() – Stand Alone *
* 3. ostream << - Stand Alone *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, or 3): 1
Calling member print() –
Left Fraction -
num: -15
denom: 11
Left Fraction -
num: -3
denom: 4
Resulting Fraction –
NULL
(How many objects were involved? XXX)
********************************
* Sub Menu -- PRINTING *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() – Stand Alone *
* 3. ostream << - Stand Alone *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, or 3): 2
Calling stand-alone print() –
Left Fraction -
num: -15
denom: 11
Left Fraction -
num: -3
denom: 4
Resulting Fraction –
NULL
(How many objects were involved? XXX)
********************************
* Sub Menu -- PRINTING *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() – Stand Alone *
* 3. ostream << - Stand Alone *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, or 3): 4
Returning to previous menu!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 2
ADDING Option –
********************************
* Sub Menu -- ADDING *
* 1. add() - Member *
* 2. add() – Stand Alone *
* 3. operator+() - Member *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, 3, or 4): 5
WRONG OPTION ...
(How many objects were involved? XXX)
********************************
* Sub Menu -- ADDING *
* 1. add() - Member *
* 2. add() – Stand Alone *
* 3. operator+() - Member *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, 3, or 4): 1
Calling member add()!
// REPLACING WITH YOUR CODE AND ACTUAL OUTPUT
(How many objects were involved? XXX)
********************************
* Sub Menu -- ADDING *
* 1. add() - Member *
* 2. add() – Stand Alone *
* 3. operator+() - Member *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, 3, or 4): 2
Calling stand alone add()
// REPLACING WITH YOUR CODE AND ACTUAL OUTPUT
(How many objects were involved? XXX)
********************************
* Sub Menu -- ADDING *
* 1. add() - Member *
* 2. add() – Stand Alone *
* 3. operator+() - Member *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, 3, or 4): 3
Calling member operator+()
REPLACE WITH YOUR CODE AND ACTUAL OUTPUT
(How many objects were involved? XXX)
********************************
* Sub Menu -- ADDING *
* 1. add() - Member *
* 2. add() – Stand Alone *
* 3. operator+() - Member *
* 4. Return to Previous MENU *
********************************
Select an option (1, 2, 3, or 4): 4
Returning to previous menu!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 3
SUBTRACTING Option –
*********************************
* Sub Menu -- SUBTRACTING *
* 1. subtract() - Member *
* 2. subtract() – Stand Alone *
* 3. operator-() - Member *
* 4. Return to Previous MENU *
*********************************
Select an option (1, 2, 3, or 4): 5
WRONG OPTION ...
(How many objects were involved? XXX)
*********************************
* Sub Menu -- SUBTRACTING *
* 1. subtract() - Member *
* 2. subtract() – Stand Alone *
* 3. operator-() - Member *
* 4. Return to Previous MENU *
*********************************
Select an option (1, 2, 3, or 4): 1
Calling member subtract()!
REPLACE WITH YOUR CODE AND ACTUAL OUTPUT
(How many objects were involved? XXX)
*********************************
* Sub Menu -- SUBTRACTING *
* 1. subtract() - Member *
* 2. subtract() – Stand Alone *
* 3. operator-() - Member *
* 4. Return to Previous MENU *
*********************************
Select an option (1, 2, 3, or 4): 1
Returning to previous menu!
(How many objects were involved? XXX)
*********************
* MENU – HW #4 *
* 1. Initializing *
* 2. Adding *
* 3. Subtracting *
* 4. Multiplying *
* 5. Dividing *
* 6. Printing *
* 7. Quit *
*********************
Select an option (use integer value only): 7
Having fun ...!
(How many objects were involved? XXX)

D. Save the program as cis25Spring2018YourNameHW4Ex1.cpp.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.