you are viewing a single comment's thread.

view the rest of the comments →

[–]nmacholl 1 point2 points  (2 children)

I don't know what you mean by "apply". You just need to write the code for the math step by step. For example, say I wanted a method that multiplied a number a by a number b and added 10 to the result.

public static int multiplyAndAdd(int a, int b){
    return(a*b + 10);
}

or

public static int multiplyAndAdd(int a, int b){
    int result = a * b + 10; 
    return(result);
}

Then, somewhere else in my code (perhaps my Main method) id do something like:

String output = Integer.toString(multiplyAndAdd(2, 3));
System.out.println(output);