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

 

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

Write a method that returns the sum of 'a', 'b', and 'c', but only include each value if the related boolean variable is 'true'. For example, only include 'a' in the sum if 'incA' is 'true'. In all of the boolean variables are 'false' return zero. Look at the test data for examples.


quiz2023_09_26_APP1SLHL_includeOrNot(-100, true, 20, true, 5000, false) → -80
quiz2023_09_26_APP1SLHL_includeOrNot(0, true, 0, true, 0, true) → 0
quiz2023_09_26_APP1SLHL_includeOrNot(-1, true, -10, true, -100, true) → -111

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

public int quiz2023_09_26_APP1SLHL_includeOrNot(int a, boolean incA, int b, boolean incB, int c, boolean incC) { }

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

Copyright Nick Parlante 2017 - privacy