ITEC 120 LAB 16 Back to Lab index page

Wrapper classes and Static methods

Write a program which will print out a table starting with 0 and go up to and including an integer number the user enters. The table will show the integer, the binary representation of that integer, the octal representation of that integer, and the hexidecimal representation of that integer.

Your program will also look at just the hexideximal numbers and count the digits and the letters contained in all the hex numbers, and report that at the end of the program.

You'll use Static methods of wrapper classes to help you with this task. You can view some of these methods in Appendix M in the book, or, on the java doc website.

Program outputs: How many numbers would you like in your table?
User inputs: 27
Program outputs: Num   Binary  Octal  Hexidecimal
0     0       0      0
1     1       1      1
2     10      2      2 
3     11      3      3
4     100     4      4
5     101     5      5
6     110     6      6
7     111     7      7
8     1000    10     8
9     1001    11     9
10    1010    12     a
11    1011    13     b
12    1100    14     c
13    1101    15     d
14    1110    16     e
15    1111    17     f
16    10000   20     10
17    10001   21     11
18    10010   22     12
19    10011   23     13
20    10100   24     14
21    10101   25     15
22    10110   26     16
23    10111   27     17
24    11000   30     18
25    11001   31     19
26    11010   32     1a
27    11011   33     1b

The total number of letters in the Hex numbers are: 8
The total number of digits in the Hex numbers are:  32

Once you have your program working, show your lab to the Peer Instructor to be checked off.