E81 CSE 131 Lecture Notes - Lecture 5: Decimal Mark, Negative Number

35 views2 pages
magentarat813 and 20 others unlocked
E81 CSE 131 Full Course Notes
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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents