Due date: See Class Webpage
1. "Nano" Numbers
Digit # ! % @ ( ) [ ] $ Value of the digit = 0 1 2 3 4 5 6 7 8 
Their number system is positional, meaning that when a number contains multiple digits, then the value of a digit is equal to 9 times the successor digit.
It happens that Neptunians use the minus sign '−' to denote negative values
Examples:
Nano number Value represent (in human decimal system)   ! 1 !# 9 !! 10 !% 11 !@ 12 !## 81 !#! 82 !#% 83 % 2 %# 18 %! 19 %% 20 (@ 39 (( 40 [[ 60 [[ 60 And so on.... 
2. Preparation
mkdir ~/cs255/hw2 cp /home/cs255001/Handouts/hw2/* ~/cs255/hw2 
If you do work from home on your PC:

I do not accept email turnins !
hw2.java: The main program that is used to test the 2 methods that you need to write for this assignment Do NOT change this file Nano.java: The Java class file that implements the 2 conversion methods specified in this assignment 
3. Assignment

which allows you to convert between:

The Nono class definition looks like this:
public class Nano { /* ========================================================== Return the 2's complement binary representation for the Nano number given in String s ========================================================== */ public static int parseNano(String s) { ... } /* ========================================================== Return the String of Nano digit that represent the value of the 2's complement binary number given in the input parameter 'value' ========================================================== */ public static String toString(int value) { ... } } 
Examples:
parseNano("#") returns the int representation: 00000000 00000000 00000000 00000000 (value = 0) parseNano("!") returns the int representation: 00000000 00000000 00000000 00000001 (value = 1) parseNano("!") returns the int representation: 11111111 11111111 11111111 11111111 (value = 1) parseNano("%") returns the int representation: 00000000 00000000 00000000 00000010 (value = 2) parseNano("%") returns the int representation: 11111111 11111111 11111111 11111110 (value = 2) parseNano("!#") returns the int representation: 00000000 00000000 00000000 00001001 (value = 9) parseNano("!!") returns the int representation: 00000000 00000000 00000000 00001010 (value = 10) 
(Recall that int uses the 2's complement number encoding scheme)
Examples:
toString(0) returns the String: "#" toString(1) returns the String: "!" toString(2) returns the String: "%" toString(9) returns the String: "!#" toString(10) returns the String: "!!" 
Note to students:

4. Test programs

5. Compile and run hw2.java
javac hw2.java 
java hw2 
The program will ask you to enter 2 Nano numbers and then:

Example 1: (my inputs are in red)
For your convenience, here are the Nano digits: Nano digit: # ! % @ ( ) [ ] $ Value of digit: 0 1 2 3 4 5 6 7 8 Enter first Nano number x = @ The value of this Nano number in decimal system = 3 Enter second Nano number y = ) The value of this Nano number in decimal system = 5 The sum in decimal number system = 8 The sum in Nano number system = $ 
Example 2: (my inputs are in red)
For your convenience, here are the Nano digits: Nano digit: # ! % @ ( ) [ ] $ Value of digit: 0 1 2 3 4 5 6 7 8 Enter first Nano number x = !%@ The value of this Nano number in decimal system = 102 Enter second Nano number y = )() The value of this Nano number in decimal system = 446 The sum in decimal number system = 548 The sum in Nano number system = [[$ 
Example 3: your program must handle negative values !!!
For your convenience, here are the Nano digits: Nano digit: # ! % @ ( ) [ ] $ Value of digit: 0 1 2 3 4 5 6 7 8 Enter first Nano number x = !%(]($ The value of this Nano number in decimal system = 75698 Enter second Nano number y = $$@)#( (Negative value !!!!) The value of this Nano number in decimal system = 527476 The sum in decimal number system = 451778 The sum in Nano number system = ])][() 
6. Turn in ********************************** You must do this !!!
cd ~/cs255/hw2 /home/cs255001/turnin Nano.java hw2 
/home/cs255001/reqext hw2 
You request will be successful if you have not exceeded the maximum number of "free" (noquestionsasked) requests allowed
Students will be graded partially on the basis of their homework assignments. These homework assignments are to be treated as examinations, and are expected to be your individual work. While discussions with other students in the course may be permitted or encouraged by your instructor, you should write your program yourself. Your instructor (and any teaching assistants assigned to the course) will be glad to help you to the extent that he or she feels reasonable. Submissions based on other students solutions in prior offerings of the course specifically violate these guidelines, as do submissions prepared with the help of an outside "tutor". You should take precautions to protect the confidentiality of your work, do not collaborate on questions that you turn in for a grade, do not show your solution to a fellow student, not even after the due date for some students may have receive extension. All submissions should include a comment statement near the top of the program of the form:
THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING A TUTOR OR CODE WRITTEN BY OTHER STUDENTS  your name 
Cases of apparent plagiarism or collusion will be referred to the Honor Council.