ITEC 120 LAB 7 | Back to Lab index page |
More Methods
Wrapper classes are described on pages 138-140 of the text. They are Java classes that allow a value of a primitive type to be "wrapped up" into an object, which is sometimes a useful thing to do. They also often provide useful methods for manipulating the associated type. Wrapper classes exist for each of the primitive types: boolean, char, float, double, int, long, short, and byte.
Write a program that uses the constants and methods of the Integer class, Character class (wrapper classes), and String class (not a wrapper class) to perform the following tasks.
You may need to refer to the documentation for the Integer class, Character class, and the String class (all in java.lang) which you can find in Appendix M of your textbook or on Sun's java website: http://java.sun.com/j2se/1.5.0/docs/api/index.html
Sample 1
Program displays: | Please enter and integer between -2147483648 and 2147483647 |
user enters: | 55555 |
Program displays: | The number 55555
in binary form is: 1101100100000011 The first digit of the hexadecimal
number is d The last digit of the hexadecimal
number is 3 |
Sample 2
Program displays: | Please enter and integer between -2147483648 and 2147483647 |
user enters: | 300 |
Program displays: | The number
300
in binary form is: 100101100 The first digit of the hexadecimal
number is 1 The last digit of the hexadecimal
number is c |