From the textbook, do Exercises 2.32, 4.31, and the following problem (also note extra instructions below).
To do these exercises, you will need the MyInput class that was shown in lecture. Paste this class into each of your own program files, and make sure to put the import java.io.* line at the top.
Programming Exercise 2.32 'Digits' Input a 5-digit number: 1234 * Not 5 digits, try again. Input a 5-digit number: 123456 * Not 5 digits, try again. Input a 5-digit number: 39485 Output: 3 9 4 8 5
Please enter a four-digit integer: 1234 1234 encrypted --> 0189
Please enter a four-digit integer: 0189 0189 decrypted --> 1234
Numbers Exercise Input integer (0 to stop) 2 Input integer (0 to stop) 4 Input integer (0 to stop) -1 Input integer (0 to stop) -5 Input integer (0 to stop) 8 Input integer (0 to stop) 0 # of positives = 3 # of negatives = 2 Total = 8 Average = 1.6
Example:
javac Numbers.java // to compile java Numbers // to run the program
tar cvf hw1.tar Ch2_32.java Ch4_31_Encrypt.java Ch4_31_Decrypt.java Numbers.javaBEFORE YOU DO THIS -- BACK UP YOUR FILES. Make sure you do not leave out the "hw1.tar" (the target file this command will create), or you will end up overwriting one of your code files.
Alternately, if you make sure that the ONLY .java files in the currect directory are these four to submit (i.e. put all your assignment files in a folder for this assignment), you can use a unix wild-card shortcut in this command:
tar cvf hw1.tar *.javaThe above version will pack ALL .java files from the current directory into the file "hw1.tar". You should see the filenames list as they are "packed" into the file, in either case. Sample output when I run the command:
myers@diablo>tar cvf hw1.tar *.java a Ch2_32.java 3K a Ch4_31_Encrypt.java 2K a Ch4_31_Decrypt.java 2K a Numbers.java 3KAfter you have packed up the files (they are now in the file called "hw1.tar"), e-mail this file as an attachment to "myers@cs.fsu.edu". The subject of your e-mail should be HW1-SUBMIT. Make sure you put your name and section number in the body of your e-mail.
If you don't know how to use the e-mail on your CS account, then you
can FTP the "hw1.tar" file to your home computer (through the SSH file
transfer feature) and e-mail from there.