Business Programming

Course announcements for INFS1609 and INFS2609

Business Programming random header image

Assignment 1

Posted by on August 2nd, 2012 · Assignments

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 the BlueJ project, Assignment1.zip. It contains three methods. You have to write the code that goes inside them.

The fist method finds the average of the elements of an integer array:

public double average(int[] data)

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.

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.

The third method is:

public int mode(int[] R)

This calculates the mode of the array elements. The mode is the value that occurs most frequently. For example the mode of the array

{1, 43, 12, 56, 88, 1, 12, 90, 90, 12, 1, 1, 1, 12, 90, 12, 12, 78}

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.

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.

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 “INFS1609″ in for the course, or select INFS1609/INFS2609 from the drop down menu and press “Search for Assignments”. Note INFS2609 students may need to enter “INFS1609″ instead of selecting INFS2609 if the assignment is not listed
  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

 

Lab Week 4 – Loops and Arrays

Posted by on August 2nd, 2012 · Labs

This week, you will download the BlueJ project Week4.zip and write methods to manipulate arrays. Two methods are given to you complete. You don’t have to do anything to them.

The method readArray

public int[] readArray()

reads a list of numbers, one per line, ending with a blank line, and returns an array containing the numbers. Don’t try to understand the details of this method. It uses things that you’ll learn about later.

The method printArray takes an integer array parameter and prints it to the terminal

public void printArray(int[] R)

The project provides templates for other methods that you have to write. Your job is to work out the code that goes inside them.

The first 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], ....

The dotProduct of two arrays returns a single integer.

public int dotProduct(int[] R1, int[] R2)

It is found by multiplying corresponding elements and adding them all up, i.e.

R1[0] * R2[0] + R1[1] * R2[1] + R1[2] * R2[2], ....

Finally, you should write a method, main,

public void main()

that reads two arrays, then:

  • calls arrayAdd and calls printArray to print the resulting array
  • calls dotProduct and prints the result

Lab Week 3 – Data Types

Posted by on July 28th, 2012 · Labs

The exercises below use the Tut3.zip project for BlueJ.

Data types

What data type would you use to represent the following values? Why?

  1. The length of a piece of string.
  2. The number of students at UNSW.
  3. A person’s age.
  4. The mass of the sun.
  5. The exact number of stars in the Milky Way.
  6. The mathematical constant π.

Expressions

What are the value and type of the following expressions? Test your answers by typing them into the Code Pad in BlueJ. Can you explain the result?

  1. 5 / 2
  2. 5 % 2
  3. 5.0 / 2
  4. 5 / 2.0
  5. 5.0 / 2.5
  6. 5.0f / 2
  7. 1.5 % 1
  8. 1 / 0
  9. 1.0 / 0
  10. 10000000000 + 1
  11. 10000000000L + 1
  12. 10000000000.0 + 1
  13. 10000000000.0f + 1

Circle area

The circleArea method in the Tut3 class calculates the area of a circle with a given radius.

  • Create a new Tut3 object and try calling this method with different input values.
  • Add breakpoint on the first line and step through the code. Watch the ‘local variable’ panel to see variables being created and change value.
  • Change the method to calculate the area of an ellipse of given width and height

Hand shaking

If there are five people Alan, Bel, Cameron, Dan, and Emily in the room and they each have to shake hands with everyone else, how many handshakes occur? What if there were 10 people? What if there were only two? Work out a general formula.

Complete the ‘handshakes’ method in the Tut3 project to use your formula to compute the number of handshakes for a given size group.

The Math Class

For more complicated mathematical expressions, Java has a lot of built in methods in the Math class. Take a look at the documentation to see what is available. Try typing the following
in CodePad. Explain the results.

  • Math.sqrt(2.0)
  • Math.round(3.1)
  • Math.round(3.7)
  • Math.min(1, 2)
  • Math.max(1, 2)

 

Lab Week 2 – Getting to know BlueJ

Posted by on July 17th, 2012 · Labs

You will be working in Quad lab 7. Experiment with the BlueJ project we saw in lectures.

  1. Login with your zPass login and password.
  2. Download the ‘Turtle’ project zip file from here .
  3. Unzip both files in your “My Documents” folder.
  4. In the ‘Start’ menu, select ‘Programs’ and click on BlueJ.
  5. Select ‘Open Project’ from the File menu and open the ‘Turtle’ project.
  6. Create a new ‘MyTurtle’ object by right clicking on the MyTurtle class and selecting new MyTurtle()
  7. Give your turtle a name and press OK.

Simple shapes

  1. Right click on the red MyTurtle object and select the void drawSquare(int sideLength) method.
  2. Enter a side length of 100 and press OK.
  3. Observe what happens in the World window.
  4. Try drawing squares of different sizes.
  5. What direction does the turtle face before and after you call the method?
  6. Double-click on the MyTurtle class to open the source-code.
  7. Read the drawSquare method. Can you explain why the turtle has a different direction after the method is called?
  8. What could you do to fix this so the turtle is facing the same way before and after the method?
  9. Change the code so that it draws a triangle instead of a square.

Using the debugger

  1. Read the method drawPolygon and try to understand how it works.
  2. Run it with different parameters to see if it does what you expect.
  3. In the source window, click on the line number for the line “if (numberOfSides < 3)“. A little red stop sign should appear.
  4. Run the method again with numberOfSides set to 6 and sideLength set to 100. The Debugger window should appear.
  5. Press the Step button and watch how the program steps through the code.
  6. Run the method again with numberOfSides set to 2. Can you predict what will happen?

Spirals

  1. Read the method drawSpiral and try to understand how it works.
  2. Try drawing a spiral with length = 10 on a piece of paper following these instructions.
  3. Use the debugger to step through the method. Does it do what you expected?
  4. Change the line ‘length = length – 2‘ to ‘length = length – 4‘. How will this change the spiral? Run it and see.
  5. Change the line to ‘length = length + 4‘. What happens now? Why?
  6. Change the line ‘rotate(90)‘ to ‘rotate(88)‘ and see what happens.
  7. Can you make other pretty patterns by making a few simple changes?

Welcome to INFS1609 & INFS2609

Posted by on July 15th, 2012 · Announcements

This course introduces you to the foundations of the programming discipline, which underlies most technical subjects such as software design, data management and algorithms. It will involve both a theoretical component (e.g. learning about basic programming concepts like loops, arrays and functions) as well as a practical component (e.g. implementing simple algorithms in a computer laboratory). The course also provides a first step towards learning the principles of object-oriented design and programming through the use of the Java programming language.

The course is suitable for students with no prior programming experience. It is particularly targeted at IS students as it relates to a number of core concepts that are essential in understanding the technologies behind information systems in business without getting overmuch into low-level technical details.

All students taking INFS1609 and INFS2609 should ensure they have read the Course Outline.

Assignment 2 & Lab marks

Posted by on October 27th, 2011 · Announcements, Assignments

Marks for Assignment 2 are now available for collection. Go to the
assignment management page:
https://cgi.cse.unsw.edu.au/~give/Student/give.php, and select INFS1609 or
INFS2609. Then select assignment1 and press Collect my Assignment.

You will be presented with your assignment log. The log contains:
* Your submitted code
* Comments from your tutor within the code
* A summary of the tests and results
* Output from incorrect tests
* Your marks
* Finally comments from your tutor

Your tutor has marked your assignment. Carefully read any comments that
your tutor may have added to your log. If you have any questions about the
results or comments contact your tutor first.

Finalised lab marks are also available and can be viewed at:
https://cgi.cse.unsw.edu.au/~give/Student/sturec.php

If you have questions about your marks please consult your tutor.

Finally, we are in the process of marking assignment 3. We will email the
course when the assignment marking has been finished. We are aiming to
have this back to you before the exam. Please do not email the course
account about assignment 3.

Consults before exam

Posted by on October 27th, 2011 · Announcements

A final consult will be held on Tuesday November 1st at 2pm. The consult will be held in building K17, Room 403.

Tutorial/Consult Week 13

Posted by on October 16th, 2011 · Labs

Instead of running tutorials this week, we will be holding consultations during the normal tutorial timeslots with the respective tutor. You are not required to attend a consultation, and no lab marks will be recorded.You may attend any consultation.
All consulatations will be held in the room K17 403.

 

Viewing Marks

Posted by on October 10th, 2011 · Announcements

You can view your labs and assignment marks at: https://cgi.cse.unsw.edu.au/~give/Student/sturec.php

Log-in with you Z-pass and select INFS1609/INFS2609 from the drop-down list. INFS2609 students may need to manually enter “INFS2609” into the search box.

Not all marks may yet be entered into the system, so please be patient. If you have any questions about your marks, ask your tutor.

Announcement on Behalf of ASB Researchers

Posted by on October 9th, 2011 · Announcements

We would like to invite you to participate in an experiment at the ASBLab. The experiment is a Java coding task that takes 1 hour. You will be asked to find and solve errors in  a Java code.

Participants will receive cash incentives based on how well they perform in the experiment. In addition, the experiment would be useful for those who are interested to practicing and confirming their java skills. The payment will vary from person to person, with a minimum of $5 and a maximum of $50.

If you would like to participate, please let us know by sending an email message to Ms Shahla Ghobadi: s.ghobadi@unsw.edu.au. In your message, please include your program (e.g., computer science, information systems) and how many years/months of experience you have in Java programming.

* Please enrol only if you are confident that you can attend the experiment, because No Shows can seriously affect the implementation of the experiment.

We hope to see you at the experiments!

Cheers,

The ASBLab researchers