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 #2: 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 multiply(int a, int b)
public static int divide(int 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 for-loop may come in handy.
Hint for the divide method: A while-loop may come in handy.
34*67 is 2278
37292 is 169
HW # 2 : Methods Open the . java file named

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!