Challenges

Remember the rules for this are

  • Try to use only the information given up to this point in this book.
  • Try not to give up until you've given it a solid attempt

Challenge 1.

RGB Colors can be represented as base 16 numbers.

The following numbers represent colors. Print them out in base 16 to figure out what colors they represent. Rename the variables to be the color names.

You should be able to just look up the hex string.

class Main {
    void main() {
        int colorA = 255;
        int colorB = 65280;
        int colorC = 16711935;
        int colorD = 16776960;

        // CODE HERE
    }
}

Challenge 2.

Rewrite the integer literals in the code from the previous challenge to be base 16 integer literals.

Challenge 3.

Add underscores in the following integer literals in the same places you would write commas in regular math (every 3 digits 13,550,145).

class Main {
    void main() {
        int a = 515326326;
        int b = 32523522;
        int c = 1221415133;
        IO.println(a);
        IO.println(b);
        IO.println(c);
    }
}