CSCI.UA0101: Homework 0 (20 points)

Updates: None. Instructions: Answer the questions stated in the following exercises by submitting plain-text or Java source code (.txt and .java extensions respectively) as stated in the exercises through NYU Classes. No word (.doc/.docx/etc.) or rich-text (.rtf) files please (in your text editor do "Save file as plain-text"). Java programs should be just the Java source code (not your .class files or Eclipse workspaces) unless otherwise stated. In all files submitted include a documentation header using comments which include: /** * [Description of the program] * @author: [Your Name and netid] */ Points will be deducted for bad coding style (up to 25% of your grade), so: - use good variable/function names (self-documenting code) - avoid hardcoding values - provide comments for complex code blocks For more details regarding good coding style guidelines see the grading criteria. At this point, you do not need to do error checking for bad input data to avoid program crashes.

Exercise 1 - Installing Java/IDE (5 points)

Downlaod and install Java SE JDK version 1.6 or higher from the java.oracle.com website. Download and install Eclipse (or another IDE if you choose; but only Eclipse will be supported) from the eclipse.org website. Once everything is installed we want to make sure everything is running smoothly. Start up Eclipse by opening the Eclipse application. Create your first Java project in Eclipse using "File -> New -> Java Project". This will create a new project which can contain as many Java files as necessary for whatever project you're working on. Name it whatever you want, but the rest of the defaults should be fine for now. Now we have an empty project, to make it useful, we'll need to add a new Class for Java to be able to run. Create a new class using "File -> New -> Class" name the class "Helloworld". Notice that you should now have a new .java file in your "Package Explorer" sidebar and new source code should have showed up in front of you. To run a program, it needs to have a main function for java to know where to start executing when run. To do that, you'll need to add a main function inside the Helloworld class code block. In Java, code blocks are defined by their corresponding curly braces ('{ ...code... }'). Insert the following code into our new classes code block: public static void main(String[] args) { System.out.println(System.getProperty("java.version")); } Now save the program ("File -> Save") and run it ("Run -> Run" or "Run -> Run as -> Java Application"). You'll notice that in the bottom Eclipse panel (the "Console") you should see a line of output. This output should be the version information (pulled from our println statement above) of the Java install that Eclipse is using. If the version doesn't start with 1.6 or higher, please make sure you're running the newly installed version Eclipse and Java. If you choose to use a command line interface (CLI) instead of Eclipse, here are some general compilation/runtime instructions: Running programs from the command line: 1. Open your favorite text editor (textedit, notepad, wordpad, gedit, vi, emacs, jedit, etc.) 2. Write your code (see sample code for examples) 3. Save the code to a known location with the filename Helloworld.java 4. Start a CLI (Mac: Use "terminal", Windows: Use Start -> Run -> "cmd", Linux: You know how) 5. On the command line, change to the directory where your Helloworld.jave file is stored ('cd PATH_TO_FILE') 6. Run 'javac Helloworld.java' to compile down to Java Bytecode 7. Run 'java Helloworld' to run the program Sample output: 1.7.0_25 Save and submit your program (just the source code) as Helloworld.java.

Exercise 2 - LiveLab Sign-up (5 points)

In some of our homework assignments, we're going to use some of the programming exercises from the textbook for this course. The LiveLab website allows you to check these programs for technical accuracy before you submit them on NYU Classes (you will not be submitting them on LiveLab). On NYU Classes there will be an announcement posted that contains two key parts of information that allow you to sign up for this service, a "Signup Code" and a "CourseID". Locate these and sign up for this service. No file submission necessary for this exercise.

Exercise 3 - LiveLab 2.5 (10 points)

Complete programming exercise 2.5 from the text. You should be able to validate your solution on LiveLab before submitting your code on NYU Classes. Remember that LiveLab only checks for technical accuracy. In addition to correctness, coding style is always in consideration when grading. So remember to use Save and submit your program (just the source code) as Exercise02_05.java. Note: Remember that code submitted should be done through NYU Classes, not LiveLab! LiveLab is just here for your convenience to verify your program.