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

 

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

Write a method that either returns the sum of 'a' and 'b' or their product. Return their sum if 'sum' is true, otherwise return the product of a and b. The values of 'a' and 'b' can be any valid integer values. Look at the test data for examples.


test2023_10_05_APP1SLHL_prodOrSum(5, 2, true) → 7
test2023_10_05_APP1SLHL_prodOrSum(-190, 180, true) → -10
test2023_10_05_APP1SLHL_prodOrSum(5, 2, false) → 10

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

public int test2023_10_05_APP1SLHL_prodOrSum(int a, int b, boolean sum) { }

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