CS 135-31 Lab Assignment 1

Wed, September 9, 2009

Required Assignment.
In this assignment you will write a Java class to operate on Hexadecimal numbers.

The input to your program are two unsigned (non-negative)  integers, separated by a blank space, and your program must first print out the hexadecimal representation of the two numbers and then print out the hexadecimal representation of the sum of the two numbers.

For example, if the input is   10 24  then your program must print out  x0000000A   x00000018  x00000022 
Assume 16 bit representation (i.e., 4 Hex digits).

Extra Points:

You now need to extend your program to handle the set of all integers (positive and negative) and using 2's complement representation (but expressed in Hex notation).  Repeat the above assignment for the general case -- i.e., set of all integers and using 2's complement representation.


Practice Problems/Optional Work:

In this extra "assignment" you will write a Java class to convert ASCI characters to text (and vice-versa).

The input to your program is a string of text representing ASCII characters in hex format (assume the input string will be on one line only). Your program must read this ASCII string and convert it to the corresponding text string. The text string is a question that you must answer but provide the answer as an ASCII string. For example, if the input is the (hex representation) string:


776861742064617920697320746F646179


The string corresponds to the text: "what day is today" If today is tuesday, then the output should be the ASCI string corresponding to Tuesday, i.e., the string:


74756573646179


Note that the ASCII characters are 2 bytes long and expressed in Hex format.

For this assignment, answer the following question:


7768617420697320796F7572206C617374206E616D65


You can use the Java code provided to you to look up the ASCII character tables. You must submit your Java code, and your answer.