I already posted this question but I gave it a try I'm not sure if I'm on the right track:

Make a util class with three methods. First method's name is add, that returns the result by adding two numbers.

Second method's name is multiply, that returns the result by multiplying two numbers.

Third's method name is division that returns a result by dividing first parameter by second parameter. How would I do this part?

This is what I've got so far:

public class Util {


public static int add(int a, int b){

int result = a + b;
System.out.println("result = " + result);

return result;
}
public static void main(String[] args) {

int res = add(5, 2);

System.out.println("res = " + res);
}

public static int multiply(int a, int b){

int result = a * b;
System.out.println("result = " + result);

return result;
}
public static void main(String[] args) {
int res = multiply(5, 2);

System.out.println("res = " + res);
}
}

3 answers

looks pretty good so far. But your best help is your IDE, or the javac error messages. If there are no compile errors, then just run your code and see what it produces. It looks like you are getting a handle on things. Just keep poking around to find code snippets that do what you want, and then adapt them to your application.
Hi Steve, I'm having trouble with this part: Third's method name is division that returns a result by dividing first parameter by second parameter. How would I do this part?
odd - you know how to do multiplication.

Do a division in the same way. Just copy the multiply routine, and replace * with /.

Be sure to watch out for division by zero.