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

 

konstans@stuy.edu set1 > sumOfEvenSquares
prev  |  next  |  chance

When both arguments are even, calculate and return the sum of the squares. When one value is odd, use double the square of the other even value. When both values are odd, return 0. Hint: Checking for even and odd can be tricky with negative numbers. The opposite of a%2==0 is not a%2==1.


sumOfEvenSquares(-2, 4) → 20
sumOfEvenSquares(1, 2) → 8
sumOfEvenSquares(-1, 2) → 8

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

public int sumOfEvenSquares(int a, int b){ }

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

Copyright Nick Parlante 2017 - privacy