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

 

test2022_09_12_P1SLHL_addPosOnly


Write a method that returns the sum of the three integer parameters, but only include numbers in the sum if they are positive. For example, with parameters 6, -2, and 1, you would return 7 because that is the sum of 6+1. You did not include the -2 in the sum because it was not positive. Look at the test data for further examples.


test2022_09_12_P1SLHL_addPosOnly(352, 23, 325) → 700
test2022_09_12_P1SLHL_addPosOnly(-124, 5334, 214) → 5548
test2022_09_12_P1SLHL_addPosOnly(1, 2, 3) → 6

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

public int test2022_09_12_P1SLHL_addPosOnly(int num1, int num2, int num3) { }

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

Copyright Nick Parlante 2017 - privacy