Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP1400 Assignment-1 Assignment 1 – Loops and Arrays Due: 11:59pm, Sunday, 04 September This assignment is about loops and 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, Assignment1.zip. It contains three methods. You have to write the code that goes inside them. Question 1 The first method finds the average of the elements of an integer array: public double average(int[] data) That is, given an integer array, data, calculate what the average of its elements are and return the average value. For example, the average of {1, 3, 2, 5, 8} is 3.8. Question 2 The second method is: public int countInRange(int[] data, int lo, int hi) For this, you have to count the number of elements of the array, data, that lie in the range lo to hi inclusive, and return the count. For example, if data is the array {1, 3, 2, 5, 8} then the call countInRange(data, 2, 5) should return 3 because there are three elements, 3, 2 and 5 that lie in the range 2 .. 5. Question 3 The third method, arrayAdd, takes two arrays as parameters and returns a new array that is the sum of the first two. public int[] arrayAdd(int[] R1, int[] R2) The addition of two arrays yields an array whose elements are the sum of the corresponding elements in the parameter arrays, i.e. R1[0] + R2[0], R1[1] + R2[1], R1[2] + R2[2], .... R1 and R2 must be of equal length. Your code must test that they are the same length and output an error message, e.g. “The arrays must be the same length”. Submission instructions From within your Assignment 1 BlueJ project, select Project -> Create Jar File… In the Dialog Box that appears: Set “Main Class” to none Ensure “Include Source” is checked Leave “Include Bluej project files” unchecked Press “Continue” Save the filename as “Assignment1.jar” Go to the Assignment1 webpage At the top of this page, Select "Make Submission" tab (see screen dump below) Click on the "Browse" button, select "Assignment1.jar" file that you just saved Click on "Submit" button Wait for the page to completely load. Then carefully read the output. If the assignment is successful you should see the following lines: ================================================ Checking your submission... Checking for Assignment1.java Assignment1.java Compiled Sucessfully Assignment1 submitted Sucessfully ================================================ If you don’t get the above output check the output to see what went wrong and resubmit. Submission notes: You can submit as many times as you wish, even after the deadline. Only your last submission will be marked. Make sure you name everything as instructed, including the classes and the submission file or the submission will not work. If you have any problems with submission, email the class account