{"id":305,"date":"2012-08-02T08:01:50","date_gmt":"2012-08-02T15:01:50","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/infs1609\/?p=305"},"modified":"2012-08-09T22:51:56","modified_gmt":"2012-08-10T05:51:56","slug":"assignment-1-draft-2","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/infs1609\/blog\/2012\/08\/assignment-1-draft-2\/","title":{"rendered":"Assignment 1"},"content":{"rendered":"<p><strong>Updated: 2012-08-07 17:00<\/strong><\/p>\n<p><strong>Due: 11:59pm Friday 17 August (i.e. the end of week 5)<\/strong><\/p>\n<p>This assignment is about arrays. You will write three methods to manipulate arrays. The first two are easy. The third one will require more thought about the design. You will submit the assignment using the CSE <strong>give<\/strong> system (see below).<\/p>\n<p>Download the BlueJ project, <a href=\"http:\/\/www.cse.unsw.edu.au\/~is1609\/12s2\/examples\/Assignment1.zip\">Assignment1.zip<\/a>. It contains three methods. You have to write the code that goes inside them.<\/p>\n<p>The fist method finds the average of the elements of an integer array:<\/p>\n<p><code>public double average(int[] data)<\/code><\/p>\n<p>That is, given an integer array, <strong>data<\/strong>, calculate the average of its elements are return the average value. For example, the average of\u00a0{1, 3, 2, 5, 8} is 3.8.<\/p>\n<p>The second method is:<\/p>\n<p><code>public int countInRange(int[] data, int lo, int hi)<\/code><\/p>\n<p>For this, you have to count the number of elements of the array, <strong>data<\/strong>, that lie in the range <strong>lo<\/strong> to <strong>hi<\/strong> <em>inclusive<\/em>, and return the count. For example, if <strong>data<\/strong> is the array\u00a0{1, 3, 2, 5, 8} then the call<\/p>\n<p><code>countInRange(data, 2, 5)<\/code><\/p>\n<p>should return 3 because there are three elements, 3, 2 and 5 that lie in the range 2 .. 5.<\/p>\n<p>The third method is:<\/p>\n<p><code>public int mode(int[] R)<\/code><\/p>\n<p>This calculates the <em>mode<\/em> of the array elements. The mode is the value that occurs most frequently. For example the mode of the array<\/p>\n<p><code>{1, 43, 12, 56, 88, 1, 12, 90, 90, 12, 1, 1, 1, 12, 90, 12, 12, 78}<\/code><\/p>\n<p>is 12 because the value 12 occurs 5 times in the array, which is more than any other value. Note that, in general, the mode may not be unique as it is possible that more than one value will occur with the same frequency. However, for this assignment, we will assume that the mode will be unique, i.e. there will only be one value with the highest occurrence.<\/p>\n<p><strong>HINT:<\/strong> You can assume that the values in the area are limited to the range 1 .. maxValue, where maxValue is some positive integer, like 10 or 100. This assumption allows you to do the counting relatively easily with clever use of arrays.<\/p>\n<h3>Submission instructions<\/h3>\n<p>You will submit your assignment to the Give automated marked system.<\/p>\n<ol>\n<li>From within your assignment 1 BlueJ project, select Project -&gt; Create Jar File\u2026<\/li>\n<li>In the Dialog Box that appears:\n<ol type=\"a\">\n<li>Set \u201cMain Class\u201d to none<\/li>\n<li>Ensure \u201cInclude Source\u201d is checked<\/li>\n<li>Leave \u201cInclude Bluej project files\u201d unchecked<\/li>\n<\/ol>\n<\/li>\n<li>Press \u201cContinue\u201d<\/li>\n<li>Save the filename as \u201cAssignment1.jar\u201d<\/li>\n<li>Open a web browser and go to\u00a0<a href=\"https:\/\/cgi.cse.unsw.edu.au\/~give\/Student\/give.php\">the give web site<\/a><\/li>\n<li>Log-in with you Z-Pass<\/li>\n<li>Either enter \u201cINFS1609\u2033 in for the course, or select INFS1609\/INFS2609 from the drop down menu and press \u201cSearch for Assignments\u201d. Note INFS2609 students may need to enter \u201cINFS1609\u2033 instead of selecting INFS2609 if the assignment is not listed<\/li>\n<li>Select \u201cassignment1\u2033 from the next drop down menu and press \u201cUpload my Assignment\u201d<\/li>\n<li>Accept the student declaration<\/li>\n<li>Press \u201cChoose File\u201d and select the \u201cAssignment1.jar\u201d file that you saved in step 4<\/li>\n<li>Press \u201cSubmit my Files\u201d<\/li>\n<li>Wait for the page to completely load. Then carefully read the output. If the assignment is successful you should see the following lines:\n<pre>================================================\r\nChecking your submission...\r\n\r\nChecking for Assignment1.java\r\nAssignment1.java Compiled Sucessfully\r\n\r\nAll files are OK\r\n================================================<\/pre>\n<\/li>\n<li>If the page doesn\u2019t load properly, that is OK just submit the assignment file again.<\/li>\n<li>If you don&#8217;t get the above output check the output to see what went wrong and resubmit.<\/li>\n<\/ol>\n<p>Submission notes:<\/p>\n<ol>\n<li>You can submit as many times as you wish, even after the deadline. Only your last submission will be marked.<\/li>\n<li>Make sure you name everything the as instructed, including the classes and the submission file or the submission will not work.<\/li>\n<li>If you have any problems with submission, email\u00a0<a href=\"mailto:is1609@cse.unsw.edu.au\">the class account<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated: 2012-08-07 17:00 Due: 11:59pm Friday 17 August (i.e. the end of week 5) This assignment is about arrays. You will write three methods to manipulate arrays. The first two are easy. The third one will require more thought about the design. You will submit the assignment using the CSE give system (see below). Download [&hellip;]<\/p>\n","protected":false},"author":328,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12998],"tags":[],"class_list":["post-305","post","type-post","status-publish","format-standard","hentry","category-assignment-1"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/users\/328"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/comments?post=305"}],"version-history":[{"count":12,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/305\/revisions"}],"predecessor-version":[{"id":324,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/posts\/305\/revisions\/324"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/media?parent=305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/categories?post=305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/infs1609\/wp-json\/wp\/v2\/tags?post=305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}