Question: HW # 2 : Methods Open the . java file named Operations.java from the Needed Files folder provided for you. Write two methods named multiply
HW #: Methods
Open the java file named Operations.java from the Needed Files folder provided for
you.
Write two methods named multiply and divide. The methods should have the following
headers:
public static int multiplyint a int b
public static int divideint a int b
The multiply method should multiply the parameter a by the parameter b However,
you may not use the multiplication operator You may only use the existing methods
of add or subtract.
The divide method should use integer division to divide the parameter a by the
parameter b However, you may not use the multiplication operator the division
operator or the mod operator.
After you complete the multiply and divide methods, uncomment the commented lines
in the main method.
If you wrote the methods correctly, your output should match the sample output below.
Hint for the multiply method: A forloop may come in handy.
Hint for the divide method: A whileloop may come in handy.
is
is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
