id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-primitives > apcsaPrimitivesMultiplyOrAddOperands2
prev  |  next  |  chance

This function multiplies the first two parameters and returns the result, or adds the first two parameters and returns the result, depending on the value of the third parameter. If the third parameter has a value greater than 0, the function returns a multiplication of the first two parameters. Otherwise, the function should return the sum of the first two parameters.


apcsaPrimitivesMultiplyOrAddOperands2(2, 4, 3) → 8
apcsaPrimitivesMultiplyOrAddOperands2(2, 4, 0) → 6
apcsaPrimitivesMultiplyOrAddOperands2(-3, 4, 5) → -12

...Save, Compile, Run (ctrl-enter)

public int apcsaPrimitivesMultiplyOrAddOperands2(int a, int b, int shouldMultiply) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 100 Post-solution available

Copyright Nick Parlante 2017 - privacy