E81 CSE 131 Lecture Notes - Lecture 5: Decimal Mark, Negative Number
magentarat813 and 20 others unlocked
8
E81 CSE 131 Full Course Notes
Verified Note
8 documents
Document Summary
The incoming parameters" types (int c and int d) The names c and d do not matter. The return type is the int before mpy. The method body contains the instructions that execute when the method is called. At that time, values are available for the parameters, and those are substituted throughout the method. I. e. if you"re multiplying 5 and 2, 5 replaces c and 2 replaces d. This if statement does not multiply a negative number through the method. If d = -1, the first return statement causes the method to terminate, returning 0. Nothing else in the method gets a chance to execute since the return statement comes right after the if statement public static int doubleit (int in) { return 2 * in; Or public static int doubleit(int in) { return mpy (in, 2); Here we reduce the problem of doubling a number to the problem of multiplying it by two.