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

 

jebbert@volusia.k12.fl.us > test2021_10_07_APSLHL_addOrSub
prev  |  next  |  chance

Write a method that returns the sum of 'a' and 'b' if 'add' is true. Otherwise, return the result of subtracting 'b' from 'a'. Look at the test data for examples.


test2021_10_07_APSLHL_addOrSub(5, 7, true) → 12
test2021_10_07_APSLHL_addOrSub(5, 7, false) → -2
test2021_10_07_APSLHL_addOrSub(8, 100, true) → 108

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

public int test2021_10_07_APSLHL_addOrSub(int a, int b, boolean add) { }

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: 205

Copyright Nick Parlante 2017 - privacy