SWE 510: Object-Oriented Programming in JavaFAll 2010Muhammad Abdulla |
General Information | Textbooks | Schedule & Notes | Projects | Policies |
Homework 3
Due: 11:59 PM, Nov. 18, 2010 Reminders: Follow the submission instructions. Remember to comment your code! Total Points: 150 0) Data Analyzer (80 points) In this homework, you will write a program to analyze numerical data in two aspects. First is statistical measurements such as minimum, maximum, and average (mean). Second is data distribution using histograms. Numerical data to be analyzed are stored in data files as text strings. For example, a data file may look like this: 1.531231 3.578735 9.55 5.8091234 ... Your program should expect 2 different command line switches: "-s" and "-h". If your program is invoked using the "-s" switch followed by the filename, it should print out the min, max, and average of numerical values. For example: $ java DataAnalyzer -s nums.dat Min: 1.531231 Max: 9.55 Average: 3.97 For histogram output, you have to find out the minimum and maximum values stored in the input data file, divide the range between minimum and maximum values into intervals, called "bins", of equals width, and count the number of values that fall into each bin. The default number of bins is 10, unless specified differently from the command line. For example, given that the range of values is [0, 100], by default the bins would be defined by intervals [0, 10), [10, 20), ..., [90,100]. Then you should count the number of values that into each of these bins, and print out the values accordingly. For example, $ java DataAnalyzer -h nums.dat 5.0 13 15.0 32 25.0 87 ... 95.0 11 The first item in each line is the value representing the bin (midpoint is chosen), and the second item is the number of numerical values that fall into that specific bin. User should be able to specify the number of bins by adding another command line argument: $ java DataAnalyzer -h nums.dat 20 2.5 3 5.0 5 ... Note: You can use the random (Gaussian) number generator (Random.java in the sample code code page (code.html) to generate sample numerical data. 1) Personal Contacts Database (70 points) In this assignment, you will design and implement a personal contacts database. Your program should support "lookup", "add", and "delete" operations, and should use a file to store contacts in a persistent storage. Each contact will have name, phone number, and address information stored. You can decide on the format of the storage file and can assume that none of the address fields will have special characters such as tabs ("\t"), new lines ("\n"), etc. Sample operations are as follows: Adding contacts: $ java Contacts -a Enter name: John Smith Enter phone #: 123-123-1234 Enter Address: 4400 University Driver, Fairfax, VA 22020 Searching contacts: $ java Contacts -s "John Smith" Name: John Smith Phone: 123-123-1234 Address: 4400 University Driver, Fairfax, VA 22020 If no flag is given, search is assumed. For example: $ java Contacts "John Smith" should return the same result as above. $java Contacts -d "John Smith" Record for John Smith has been deleted. $java Contacts "John Smith" No record found for John Smith. Your program should behave gracefully in cases of erroneous input. You can use a default file name to store your contacts, but do not have support any command line switches for choosing the contacts file. Only one file should be used for storing contacts. You can ignore the possibility of concurrent modifications to your database (no need to lock and synchronize). |
Date & Time
![]() ![]()
What is New?
|