Docsity

CSCI 455 Programming Systems Design: Student Database Management, Assignments of Music

Toggle sidebar
bg1
Programming Systems Design
CSCI 455
FALL 2009
Dr. K. Narayanaswamy
Programming Assignment # 6
Due Date: 10/18/2009 (11:59:59 p.m.)
Goal
This assignment requires you to understand how to manage a collection of structure objects in a
way that resembles a real-world database. It significantly extends the functionality of
Assignment 5 by allowing for you to add students and delete students from the collection. You
will learn to use algorithms such as insertion sort and sequential or binary search. We will
improve the efficiency of these algorithms as we make further progress in the days to come. You
are expected to learn and to design and use functions in C++ using the general style of the
examples done in class, including declaration of parameters.
Task
The program will manage a database of Student objects. As in Assignment 5, the following are
the attributes of a student:
Last name: a string with only alphabetic characters. For formatting purposes, you
may assume the names would be no longer than 15 characters;
First name: a string with only alphabetic characters. For formatting purposes, you
may assume the first name would be no longer than 15 characters;
Social Security Number: a string. The social security numbers you accept must be
11 characters, with digits in positions 1, 2, 3, 5, 6, 8, 9, 10 and 11; and the “-“ in
positions 4 and 7.
Phone Number: a string. A valid phone number will be of length 13, and will
contain characters “(“ in position 1, “)” in position 5, and “-“ in position 9. All other
characters must be digits.
Age: an integer. You may assume this field will always be an integer, but the age
must be a positive integer.
Your program will support the following single character commands in a main command loop:
“I” or “i” (Import Command) Prompts the user for a file name, and will initialize
the database from the student data in that file. That means that existing database
pf3
pf4
pf5
pf8

Partial preview of the text

Download CSCI 455 Programming Systems Design: Student Database Management and more Assignments Music in PDF only on Docsity!

Programming Systems Design

CSCI 455

FALL 2009

Dr. K. Narayanaswamy Programming Assignment # 6 Due Date: 10/18/2009 (11:59:59 p.m.) Goal This assignment requires you to understand how to manage a collection of structure objects in a way that resembles a real-world database. It significantly extends the functionality of Assignment 5 by allowing for you to add students and delete students from the collection. You will learn to use algorithms such as insertion sort and sequential or binary search. We will improve the efficiency of these algorithms as we make further progress in the days to come. You are expected to learn and to design and use functions in C++ using the general style of the examples done in class, including declaration of parameters. Task The program will manage a database of Student objects. As in Assignment 5, the following are the attributes of a student:  Last name: a string with only alphabetic characters. For formatting purposes, you may assume the names would be no longer than 15 characters;  First name: a string with only alphabetic characters. For formatting purposes, you may assume the first name would be no longer than 15 characters;  Social Security Number: a string. The social security numbers you accept must be 11 characters, with digits in positions 1, 2, 3, 5, 6, 8, 9, 10 and 11; and the “-“ in positions 4 and 7.  Phone Number: a string. A valid phone number will be of length 13, and will contain characters “(“ in position 1, “)” in position 5, and “-“ in position 9. All other characters must be digits.  Age: an integer. You may assume this field will always be an integer, but the age must be a positive integer. Your program will support the following single character commands in a main command loop:  “I” or “i”  (Import Command) Prompts the user for a file name, and will initialize the database from the student data in that file. That means that existing database

contents will be wiped out completely and re-initialized when this command is executed. The data in the array must be maintained in sorted order – sorted by social security number. The command should check for and report errors as the input file is processed. The format of the data and error checking requirements are identical to that in Assignment 5. In all cases, IF there are any problems with the input, you should report the problem to the terminal to make the user aware with a line number on which the problem arises. You should also specify what action was taken with the input. You may assume the input will have the above items in the order stated in the input file. You do not have to do error checking beyond what is indicated explicitly in the assignment requirements.  “A” or “a”  (Add Command) Add a Student to the database you are maintaining – your program should prompt for each of the student attributes (such as social security number, last name, first name, phone, and age). Make sure that the attributes provided as values satisfy the requirements – e.g., social security number must be valid, age must be positive, and so on. Once all the data is validated, your program should add the new student to the existing database if there is no duplicate social security number. It is critical that the addition preserves the sorted order. You should detect if a student with the same social security number exists in the database and provide an error message about this situation. The program should validate the data for a part prior to adding it to the database.  “D” or “d”  (Display Command) This command should ask the user for a social security number of a student to display. The command should find the student in the database and display the student’s data TO THE TERMINAL. If a student with that social security number does not exist, print a message to the effect. You should display the student data in any format that is readable.  “R” or “r”  (Remove Command) This command should ask the user for a student’s social security number. The command should then delete that student from the database. If a student with that social security number does not exist, print a message to that effect.  “E” or “e”  (Export Command) Prompts the user for a file name, and will export or save the entire database of students from the array into the named file. If the output file name is the same as the input file, you should confirm that the user wants to overwrite the input data. Note that the output file should be saved in an identical format to the input file , so that the output file can itself be used to import new data in a subsequent run of the database program.  “S” or “s”  (Show All Command) Shows ALL the students in the current database to the terminal in a readable format. You can use any format that is readable.  “Q” or “q”  (Quit Command) should quit the main command loop and exit the program.

Ignoring Record Number 9 – bad phone number Ignoring Record Number 10 – duplicate ssn Processed 10 student records 4 invalid records were found Enter command (A, D, E, I, R, S – or Q to quit) : s Last Name First Name Social Security # Phone # Age Biggins Bill 000-89-2000 (619)555- 29 Rigney Bill 000-90-2000 (310)555- 23 Swartough John 111-23-2000 (323)555- 29 Vilnius Kostas 128-85-2005 (909)555- 32 Anderson Jim 235-90-2000 (626)555- 24 Tyler Hayden 333-90-2000 (818)555- 30 Enter command (A, D, E, I, R, S – or Q to quit) : A Enter ssn: 345-67- Enter last name: Jones Enter first name: Edith Enter phone number: (310)555- Enter age: 35 Student added… Enter command (A, D, E, I, R, S – or Q to quit) : s Last Name First Name Social Security # Phone # Age Biggins Bill 000-89-2000 (619)555- 29 Rigney Bill 000-90-2000 (310)555- 23 Swartough John 111-23-2000 (323)555- 29 Vilnius Kostas 128-85-2005 (909)555- 32 Anderson Jim 235-90-2000 (626)555- 24 Tyler Hayden 333-90-2000 (818)555- 30 Jones Edith 345-67-8890 (310) 555-5656 35 Enter command (A, D, E, I, R, S – or Q to quit) : r Enter ssn to remove: 235-90- Student removed Enter command (A, D, E, I, R, S – or Q to quit) : s Last Name First Name Social Security # Phone # Age

Biggins Bill 000-89-2000 (619)555- 29 Rigney Bill 000-90-2000 (310)555- 23 Swartough John 111-23-2000 (323)555- 29 Vilnius Kostas 128-85-2005 (909)555- 32 Tyler Hayden 333-90-2000 (818)555- 30 Jones Edith 345-67-8890 (310) 555-5656 35 Enter command (A, D, I, R, S – or Q to quit) : D Enter ssn to display: 000-90- Last Name First Name Social Security # Phone # Age Rigney Bill 000-90-2000 (310)555- 23 Enter command (A, D, E, I, R, S – or Q to quit) : E Enter output file name: foobar.txt Database saved to foobar.txt Enter command (A, D, E, I, R, S – or Q to quit) : Q Exiting the database program…

Grading Criteria: The following are the grading criteria for this assignment. You should use this as a checklist prior to submission if you want to get full credit for it. PROGRAM CORRECTNESS: 80 points I command works correctly if fields are right 8 E command exports file in the same format as input file 8 A command works correctly if inputs are right 8 A and I command exclude bad ssn, bad telephone, bad age 4 A and I command ensure no duplicate ssn’s in the database 4 R command removes a student with a particular ssn if found 8 R command provides an error message if not found 2 D command displays a student with a particular ssn if found 8 D command provides an error message if not found 2 S command shows ALL the student data correctly 8 Q command quits the program correctly 2 Illegal commands are properly detected and handled 3 Requirements Carried Forward from the Prior Assignment (no positive points – but –5 per requirement that you do not satisfy):  Detects and excludes bad SSN  Detects and excludes bad phone number  Detects and excludes bad age  Use a Function to check validity of social security number  Use a Function to check validity of phone number  Use a Function to read the input file (will be called by the Import command)  Use a Function to write the output file (will be called by the Export command)  Problems with input file or output file opens detected and handled properly

Program uses a function to delete a student with a particular ssn 5 Program uses a common function to display a single student to the terminal (to be called from D and S commands)

Program uses a common function to add a single Student to the database (to be called from I and A commands)

PROGRAM DESIGN & STYLE: 20 points Program uses an array of struct to represent Student data 5 Program is easy to change to different numbers of students 5 Program is readable (indentation and mnemonic variables) 5 Program is documented (header, functions and the major steps/loops of program)