Question
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
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 nam e 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.
i. There must be as least 4 constructors of
ii. Default,
iii. Copy,
iv. Convert taking on an int.
v. One constructor with 2 arguments of int.
The constructor should have code to confirm the call/use of itself through the printing (e.g., Calling Fraction(int, int)) and continue with the display of numerator and denominator after being initialized/built.
3. Provide get()/set() method members for each private data member.
4. Provide a method member print() that will print the current Fraction object.
B. Provide the following member methods,
a. A method add() to add a Fraction object; and
b. A method subtract() to subtract a Fraction object; and
c. A method multiply() to multiply a Fraction object; and
d. A method divide() to divide a Fraction object; and
C. Provide the following stand-alone (non-member) methods,
a. A method init() to set up or update the 3 required Fraction objects.
b. A method add() to add 2 Fraction objects; and
c. A method subtract() to subtract 2 Fraction objects; and
d. A method multiply() to multiply 2 Fraction objects; and
e. A method divide() to divide 2 Fraction objects; and
f. A method print() to print the required Fraction objects; and
g. An appropriate menuHw5() method to produce the required output as displayed below.
D. Write a menu program to produce and display the output as specified as below,
/** REQUIRED PROGRAM OUTPUT
CIS 36A Java Programming Laney College
Your Name
Assignment Information -- Assignment Number: Homework 04,
Coding Assignment -- Exercise #1
Written by: Your Name Submitted Date: Due Date
*********************
* 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 -- lOp : null
rOp : null resultingFr : null
*********************
* 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!
*********************
* 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!
**************************
* SubMENU INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 5 WRONG OPTION!
**************************
* 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 Right Fraction Enter num: 3
Enter denom: -4
Right Fraction num: -3
denom: 4
**************************
* SubMENU INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 2
Updating 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
******************************
* SubMENU UPDATING *
* 1. Left Fraction *
* 2. Right Fraction *
* 3. Left & Right Fractions *
* 4. Returning *
****************************** Select an option (integer only): 4
Returning to previous menu!
**************************
* SubMENU INITIALIZING *
* 1. Creating *
* 2. Updating *
* 3. Returning *
**************************
Select an option (integer only): 3 Returning to previous menu!
*********************
* 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
********************************
* PRINTING MENU *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() Stand Alone *
* 3. 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
********************************
* PRINTING MENU *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() Stand Alone *
* 3. 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
********************************
* PRINTING MENU *
* (leftOp, rightOp, result) *
* 1. print() - Member *
* 2. print() Stand Alone *
* 3. Return to Previous MENU *
******************************** Select an option (1, 2, or 3): 3
*********************
* 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
********************************
* ADDING MENU *
* *
* 1. add() - Member *
* 2. add() Stand Alone *
* 3. Return to Previous MENU *
******************************** Select an option (1, 2, or 3): 5
WRONG OPTION ...
********************************
* ADDING MENU *
* *
* 1. add() - Member *
* 2. add() Stand Alone *
* 3. Return to Previous MENU *
******************************** Select an option (1, 2, or 3): 1
Calling member add()
// To be discussed
// - REPLACE WITH YOUR CODE AND ACTUAL OUTPUT
********************************
* ADDING MENU *
* *
* 1. add() - Member *
* 2. add() Stand Alone *
* 3. Return to Previous MENU *
******************************** Select an option (1, 2, or 3): 2
Calling stand alone add()
// To be discussed
// - REPLACE WITH YOUR CODE AND ACTUAL OUTPUT
********************************
* ADDING MENU *
* *
* 1. add() - Member *
* 2. add() Stand Alone *
* 3. Return to Previous MENU *
******************************** Select an option (1, 2, or 3): 3
*********************
* 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
*********************************
* SUBTRACTING MENU *
* *
* 1. subtract() - Member *
* 2. subtract() Stand Alone *
* 3. Return to Previous MENU *
********************************* Select an option (1, 2, or 3): 5
WRONG OPTION ...
*********************************
* SUBTRACTING MENU *
* *
* 1. subtract() - Member *
* 2. subtract() Stand Alone *
* 3. Return to Previous MENU *
********************************* Select an option (1, 2, or 3): 1
// To be discussed
// - REPLACE WITH YOUR CODE AND ACTUAL OUTPUT
*********************
* 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 ...!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started