COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Assignment 1 – Loops and Arrays

Posted by on August 15th, 2013 · Assignments

Due: 11:59pm Sunday 1 September (i.e. the end of week 5)

This assignment is about loops 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], ....

Submission instructions

You will submit your assignment to the Give automated marked system.

  1. From within your assignment 1 BlueJ project, select Project -> Create Jar File…
  2. In the Dialog Box that appears:
    1. Set “Main Class” to none
    2. Ensure “Include Source” is checked
    3. Leave “Include Bluej project files” unchecked
  3. Press “Continue”
  4. Save the filename as “Assignment1.jar”
  5. Open a web browser and go to the give web site
  6. Log-in with you Z-Pass
  7. Either enter “COMP1400″ in for the course, or select COMP1400 from the drop down menu and press “Search for Assignments”. Note INFSi1609/2609 students may need to enter “COMP1400″ instead of selecting the course form the dropdown
  8. Select “assignment1″ from the next drop down menu and press “Upload my Assignment”
  9. Accept the student declaration
  10. Press “Choose File” and select the “Assignment1.jar” file that you saved in step 4
  11. Press “Submit my Files”
  12. 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
    
    All files are OK
    ================================================
  13. If the page doesn’t load properly, that is OK just submit the assignment file again.
  14. If you don’t get the above output check the output to see what went wrong and resubmit.

Submission notes:

  1. You can submit as many times as you wish, even after the deadline. Only your last submission will be marked.
  2. Make sure you name everything the as instructed, including the classes and the submission file or the submission will not work.
  3. If you have any problems with submission, email the class account

 

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.