Labs

  1. Create a program with a method that takes an int parameter. The method should loop from 1 to that number, printing each number in hexadecimal, decimal, and octal. Call this method from main.

(Solution: PrintNumbers.java)

  1. Modify your program to include the binary number in the output. Test by printing the numbers up to 66,000.

(Solution: PrintNumbers2.java)

  1. Modify your program to print the numbers in fixed-width columns. Hexadecimal numbers should be padded with leading zeros and be prefixed 0x. Binary numbers should be prefixed with 0b. Octal numbers should be prefixed with a single 0.

(Solution: PrintNumbers3.java)


Prev -- Up