Due: See class webpage
The examples shown in class only supported the string and integer data types.
In this project, you will apply the technique to write a program that can handle string, integer and double data types.
The Java program in this project will in the data stored in the "db-data" file (using the meta data information stored in the file "db-description") and prints the records and then finds (and prints) the smallest (minimum) of the value of a specific field
The lecture notes on the topic can be found here: click here ---- study them if you missed the class or need further information on the programming technique (that was discussed in class).
mkdir ~/cs377/pj1 cp /home/cs377001/Handouts/pj1/* ~/cs377/pj1 |
After copying the files, you can work on your project on a MathCS lab machine (in the MathCS lab).
You can work on a MathCS lab machine through "remote login". To work on a MathCS lab machine remotely (from your dorm or apartment on your laptop); you must follow the instruction on this webpage to set up your laptop (if you have not done it before).
DataFile.java: the file manipulation class I used to write the programs. Do NOT change this file pj1.java: a skeleton Java program You must complete this program as assignment Look for TODO tags inside the file and do the task |
The format of the meta data file db-description is:
Format of the Meta data: +-----------+-----------+-----------+ | fieldName | fieldType | fieldSize | +-----------+-----------+-----------+ fieldName = the name of the field fieldType = the data type of the field "C" = Characters (String) "I" = Integer "F" = Double precision floating point number or double fieldSize = the number of bytes used to store the value |
|
Look inside the file pj1.java and look for places that contains the TODO tag.
You need to write Java definition/statements to accomplish the TODO items.
javac pj1.java |
java pj1 FieldName |
UNIX>> java pj1 ID Field: ID, type: I, size: 4 Field: ItemName, type: C, size: 10 Field: Price, type: F, size: 8 Field: Inventory, type: I, size: 4 Finish reading data description file.... The data file contains these records: -999 Apple 78.98 -89 -888 Orange -99.99 98 -452 Grape -89.99 -99 -872 Peach 1234.0 -567 -567 Pear 5678.0 99 Find min value in the field ID Min = -999 |
|
|
You program must work with every data files
cp db-data.2 db-data cp db-description.2 db-description |
The field names of db-data.2 are: StudID, CumCredits and GPA.
Now run your program without making any change using the new field names !!!
In other words, you program must still work without editing and compiling when you run this command:
java pj1 GPA // Print the min value of the GPA |
cp db-data.3 db-data cp db-description.3 db-description |
The field names of db-data.3 are: SSN, Age and Sal.
Now run your program without making any change using the new field names !!!
In other words, you program will still work if you run it as:
java pj1 Sal // Print the min value of the Sal field |
/home/cs377001/turnin pj1.java pj1 |
/home/cs377001/req-ext pj1 |
You request will be successful if you have not exceeded the maximum number of "free" (no-questions-asked) requests allowed
Students will be graded partially on the basis of their homework assignments. These homework assignments are to be treated as examinations, and are expected to be your individual work. While discussions with other students in the course may be permitted or encouraged by your instructor, you should write your program yourself. Your instructor (and any teaching assistants assigned to the course) will be glad to help you to the extent that he or she feels reasonable.
Submissions based on other students solutions in prior offerings of the course specifically violate these guidelines, as do submissions prepared with the help of an outside "tutor".
You should take precautions to protect the confidentiality of your work, do not collaborate on questions that you turn in for a grade, do not show your solution to a fellow student, not even after the due date for some students may have receive extension.
All submissions should include a comment statement near the top of the program of the form:
THIS CODE IS MY OWN WORK, IT WAS WRITTEN WITHOUT CONSULTING A TUTOR OR CODE WRITTEN BY OTHER STUDENTS - your name
Cases of apparent plagiarism or collusion will be referred to the Honor Council.