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

 

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

Given two int values a and b and a boolean shouldMultiply, multiply the parameters if the third parameter has the value true, and return the result of the multiplication. If the third parameter has the value false, add the parameters instead and return the sum.


apcsaPrimitivesMultiplyOrAddOperands1(2, 4, true) → 8
apcsaPrimitivesMultiplyOrAddOperands1(2, 4, false) → 6
apcsaPrimitivesMultiplyOrAddOperands1(-3, 4, true) → -12

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

public int apcsaPrimitivesMultiplyOrAddOperands1(int a, int b, boolean 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