Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Performing operations without using ARithmetic Operators

1. ## Performing operations without using ARithmetic Operators

Guys!
Please help me I have this lab exercise and I really dont know what to do.. Im desperate
My professor posted this:
Objectives:
- To let the participants experience the use of loops and operators.

Create a Java Application using the class BasicMathOperation. The application will initialize two integer values and display the ff:
a. Product without using the multiplication (‘*’) operator.
b. Integer quotient without using the division (‘/’) operator.
c. Integer remainder without using the modulo (‘%’) operator.
d. Take note that inside the whole code, you are NOT allowed to use the ff: operators: ‘*’, ‘/’, and ‘%’.

Save your file as ICS112_Section_Exercise3_Surname_ComputerNumber.ja va (ie: ICS112_1ITB_Beltran_25.java)

Class BasicMathOperation UML Diagram
BasicMathOperation
- operand1 : int
- operand2 : int
//constructor
+ BasicMathOperation(int num1, int num2)
//setters
+ setOperand1(int num1) : void
+ setOperand2(int num2) : void
//getters
+ getOperand1() : int
+ getOperand2() : int
//basic methods
+ multiplyUsingLoop() : int
+ divideUsingLoop() : int
+ moduloUsingLoop() : int
Note: To avoid division by zero, the operand2 must have no value of zero. Same is true to modulo by zero, that is, the operand2 must have no value of zero. And this condition must be checked in the methods divideUsingLoop() and moduloUsingLoop(). If this happen, the output is “Error division by zero” or “Error modulo of zero”, respectively. And the program exit using the command System.exit(1).

2. ## Re: Performing operations without using ARithmetic Operators

Harness that desperation and make an effort to understand the assignment, formulate a design, and write some code. We can't help you with code, but I can suggest that you work the problem one piece at a time and work it through, breaking it into even smaller, more manageable pieces, if necessary. When you have some code that you need help with, please come back. Post code and any errors you want help with, code posted in code tags.

Good luck!

3. ## Re: Performing operations without using ARithmetic Operators

Thank you thank you I'll do that.

--- Update ---

I dont know how to start.. Im just a beginner and Ive been searching about this topic for how many hours. My professor didnt taught us how to do this. He just posted this. Help help help