Class Warmup

java.lang.Object
  extended by Warmup

public class Warmup
extends java.lang.Object

A set of static methods you need to implement for this Java warmup. These method all involve integer parameters, and many require you to perform operations such as division and reminder. Using bit operations (shifting and masking) is useful for several, although not strictly needed. Do not change the method names or arguments. If you do, the tests will fail. In each method, replace the "throw new Unsupported..." statement with your implementation. Those throw statements are there to indicate which functions you haven't gotten around to implementing yet.


Method Summary
static int bitCount(int x)
          Return the number of 1 bits in the binary representation of x
static int distinctValues(int x, int y, int z)
          Return the number of distinct values passed as arguments
static int firstDigit(int x)
          Return the first digit of the base ten representation of x; will only return 0 if x == 0
static boolean isOdd(int x)
          Return true if x is odd

Method Detail

isOdd

public static boolean isOdd(int x)
Return true if x is odd


firstDigit

public static int firstDigit(int x)
Return the first digit of the base ten representation of x; will only return 0 if x == 0


distinctValues

public static int distinctValues(int x,
                                 int y,
                                 int z)
Return the number of distinct values passed as arguments


bitCount

public static int bitCount(int x)
Return the number of 1 bits in the binary representation of x



Web Accessibility