Assignment 1

Due on Tuesday 3rd February

You may work in pairs if desired. Plan and think out carefully before you start programming.

Question 1:

Write a program which will offer two ways to handle data to be analysed; the data being a collection of numbers (doubles). The 'analysis' will comprise finding the max and the min of the collection of numbers, as well as the mean* and the standard deviation*. The first way of gathering the data should invite the user to type in numbers at the keyboard once the program has been started, with the 'typing' of an empty string or the typing of a non-number being used to terminate the list of numbers. The second choice to be provided should ask the user for the name of a file to be read from, this file containing a space separated list of 'doubles' spread over several lines. When the program starts, it should ask the user if they'd prefer to type in data or give the name of a file holding the data, and then run accordingly. In both cases the answer should be displayed on the screen, though an option should be provided to write the analysis data to a file whose name has also been asked for by the program. (The goal here is to develop a program for data anaylsis of large files, so the 'first case' is just a way of encouraging you to start simply!)

You should now see if you can improve your program so that it can give you more insight into the data being analysed (e.g., how uniform is it? how wild are the outliers (if any)? etc.). Use your imagination here to build something potentially useful, and ask questions if unsure what to do.

* The mean, m, of a list of numbers, (a1, a2, a3, ..., an), is the average, ie   m = (a1 + a2 + ... + an) / n ; and the standard deviation, s, is the square root of the average of the squares of the differences between the numbers and the mean, ie   s = sqrt[ ( (a1 - m)^2 + (a2 - m)^2 + ... + (an - m)^2 ) / n ] . (Note that there is some variation in the stats community about whether to divide by n or (n-1) when computing the standard deviation. This arises perhaps since dividing by n fits within the whole theory of moments, which puts things like means, std devs, skewness, kurtosis, etc in a consistent framework, whereas dividing by (n-1) reflects nicely the numbers of degrees of freedom, which fits well within sampling theory. Since there are good arguments for adopting each version, we'll adopt the division by n version simply to aim for consistency of answers within the course.)

Question 2:

Build a banking system. We may well revisit this later to add some more sophisticated security, but for now you should treat this as an opportunity to play with classes. You should have a class Bank to manufacture banks (and have at least two bank objects contructed), a class Person to make people (and have several different people built), a class Shop to make shops (have at least three shops), a class CredCardCo to make credit card companies (have at least two such companies), a class Employer to make employers (have at least two employers, and consider the possible relationship with the companies already built; think inheritance), and any other classes that you think might be helpful.

You should include such fields and methods as make sense to model the interactions amongst these entities, for example, salaries, purchases, loans, accounts. You should also consider how to ensure reasonable privacy of information (we'll investigate this topic later in the course in rather greater depth), viable approaches to authentication (passwords would be a start ...), and good consistency of data (spending money should result in a transfer of money from the spender to the receiver!). Note that typically a credit card company will charge a percentage (usually in the range of 3% to 5%) on the stated purchase price (thus giving less to the receiver) as a way of getting income. You should design your classes and overall testing program so that it's easy to modify any of the main ingredients (e.g., change interest rates).