COS 126 Assignment 0 |
Programming Assignment Due: 11:55pm |
The purpose of this assignment is to introduce you to programming in Java and familiarize you with the mechanics of preparing and submitting assignment solutions. Your goal this week is to learn to use DrJava for editing programs, javac for compiling them, java for executing them, and Moodle for submitting them.
Hello, World. In this step, you will setup an environment for developing Java programs.
Programming. In this part, your job is to write four short programs. We'll assume that you've already created, compiled, and executed HelloWorld.java by following the instructions in the previous part of the assignment. Before completing this part, you should read Sections 1.1 and 1.2 in the textbook.
% java HiTwo Alice Bob Hi, Alice! Have you met my friend Bob?
% java Ordered 10 17 49 true % java Ordered 49 17 10 true % java Ordered 10 49 17 false
z = (-2 ln u)^{1/2} sin(2 π v)where u and v are real numbers between 0 and 1 generated by Math.random(). Note that Math.PI is the mathematical constant π, Math.log(x) is the natural logarithm of x, Math.sqrt(x) is the square root of x, and Math.sin(x) is the sine of x in radians.
% java StdGaussian 0.9500138326397604 % java StdGaussian -0.6001188427428142
Hint. Math.min(x, y) returns the minimum of x and y.
% java RGBtoCMYK 75 0 130 // indigo cyan = 0.4230769230769229 magenta = 1.0 yellow = 0.0 black = 0.4901960784313726
Writeup. With each assignment you must submit a text file named readme.txt that is a narrative description of your work. We provide a readme.txt that you should use as a template. Download this file and answer all questions in the space provided.
Browsing the course website. The next part of the assignment is to browse the COS 126 Web pages. The address is:
Cruise around the COS 126 Web site; it is essential that you understand what's where and how to get to it. Be sure to fill out the online questionnaire. Also make sure you find the Assignment 0 checklist page, and also be sure to read the COS 126 Collaboration Policy and answer the related questions in your readme file.http://www.princeton.edu/~cos126
Submitting the assignment. The final part of the assignment is to submit HiTwo.java, Ordered.java, StdGaussian.java, RGBtoCMYK.java, and readme.txt via the Web submission system. To do this, go to the course webpage and select the HelloWorld assignment under Social Activities. Be sure to hit the Run Script button to check your program against our Java compiler. It should compile without errors or warnings; if not, fix the problem and resubmit it. To submit a file, you must be officially registered for the course.