{"id":386,"date":"2012-08-06T19:51:29","date_gmt":"2012-08-07T02:51:29","guid":{"rendered":"http:\/\/blogs.unsw.edu.au\/comp1400\/?p=386"},"modified":"2012-08-06T19:51:29","modified_gmt":"2012-08-07T02:51:29","slug":"assignment-1","status":"publish","type":"post","link":"https:\/\/blogs.unsw.edu.au\/comp1400\/blog\/2012\/08\/assignment-1\/","title":{"rendered":"Assignment 1"},"content":{"rendered":"<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 give 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, data, calculate the average of its elements are return the average value. For example, the average of {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, data, that lie in the range <code>lo<\/code> to <code>hi<\/code> <strong>inclusive<\/strong>, and return the count. For example, if data is the array {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 <strong>mode<\/strong> 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>HINT: 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<p><strong>Submission instructions<\/strong><\/p>\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 <strong>Project -&gt; Create Jar File\u2026<\/strong><\/li>\n<li>In the Dialog Box that appears:<\/li>\n<ol>\n<li>Set \u201c<strong>Main Class<\/strong>\u201d to none<\/li>\n<li>Ensure \u201c<strong>Include Source<\/strong>\u201d is checked<\/li>\n<li>Leave \u201c<strong>Include Bluej project files<\/strong>\u201d unchecked<\/li>\n<li>Press \u201c<strong>Continue<\/strong>\u201d<\/li>\n<li>Save the filename as \u201c<strong>assignment1.jar<\/strong>\u201d<\/li>\n<\/ol>\n<li>Open a web browser and go to <a href=\"https:\/\/cgi.cse.unsw.edu.au\/~give\/Student\/give.php\">the give web site<\/a><\/li>\n<ol>\n<li>Log-in with your Z-Pass<\/li>\n<li>Enter \u201cCOMP1400\u2033 in for the course and press \u201c<strong>Search for Assignments<\/strong>\u201d. <\/li>\n<li>Select \u201cAssignment1\u2033 from the next drop down menu and press \u201c<strong>Upload my Assignment<\/strong>\u201d\n<\/li>\n<li>Accept the student declaration<\/li>\n<li>Press \u201c<strong>Choose File<\/strong>\u201d and select the \u201cassignment1.jar\u201d file that you saved in step 4<\/li>\n<li>Press \u201c<strong>Submit my Files<\/strong>\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<p><code>Checking your submission...<br \/>\nChecking for relevant classes...<br \/>\nAll files are OK<\/code><\/p>\n<p>If the page doesn\u2019t load properly, that is OK just submit the assignment file again.<br \/>\nIf you see the final line, everything is good. Otherwise check the output to see what went wrong and resubmit.<\/li>\n<\/ol>\n<\/ol>\n<p><strong>Submission notes:<\/strong><\/p>\n<p>You can submit as many times as you wish, even after the deadline. Only your last submission will be marked.<br \/>\nMake sure you name everything the as instructed, including the classes and the submission file or the submission will not work.<br \/>\nIf you have any problems with submission, email the class account<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 the BlueJ project, [&hellip;]<\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[468],"tags":[],"class_list":["post-386","post","type-post","status-publish","format-standard","hentry","category-assignments"],"_links":{"self":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":5,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/386\/revisions"}],"predecessor-version":[{"id":391,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/posts\/386\/revisions\/391"}],"wp:attachment":[{"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/media?parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/categories?post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.unsw.edu.au\/comp1400\/wp-json\/wp\/v2\/tags?post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}