Lab #3 Assignment

CSE 1320-001

Fall 2010

Due Date:        See class website for due date

(see instructions on website for how to turn this in - Òlab submission infoÓ)

Grade value:     13% out of 100% for all grades

 

Objective: The goal for this lab is to provide an opportunity for practice of C program development and the C programming topics and further analysis and design skills. It is assumed that the student is familiar with and can use all the concepts in those chapters. This assignment is designed to practice those concepts by creating a C program. This assignment builds on Lab #2 and reinforces and refreshes previously learned material about C programming.

 

Every lab assignment allows students to practice program development, debugging, and testing. All of these skills are crucial to success in Dr. TÕs class. As you work on this lab assignment you are encouraged to ask the instructor or TA about any concepts you are unsure of.

 

Topics:

              Linked lists

              Structs and bit fields

              Enumerated types

              Unions

              File I/O

              Command line parameters

 

Plan: Dr. T gives an overall problem that students work on all semester. Each lab assignment implements specific concepts. Succeeding assignments will modify and extend previous assignments.

 

Overview: You are going to put together a small database of information about certain people. You are going to get information from the user and store that information in a certain way. WeÕll call this the data-entry phase of the program. Once all the input data is entered, your program will allow another user to perform various tasks on the data by choosing tasks from a menu. WeÕll call this the menu-driven phase of the program. The user can continue to choose tasks from the menu as long as desired and one of the menu choices must be to end the program. The program ends correctly when the user chooses that option.

 

You are also required to design your program in advance before you begin writing code. You will document your design and turn in the design document at least a week before the lab assignment is due. The goal of the design document is to assist you in developing the actual program.

 

This assignment has an overview section, a task description section, an implementation requirements section, a grading scale, and a deductions section. If there is additional info needed it will be in a miscellaneous section at the end of this lab assignment. Read ALL of the assignment before you start trying to develop the program.

 

This lab assignment looks similar to the previous assignment but it has many differences. Read it carefully and do not assume that everything from the previous lab is the same this time.

 

Be sure to check the DEDUCTIONS section at the end of this assignment to avoid penalties. You may NOT use global variables, the exit command, goto, break (except in a switch), or continue.

 

Assumptions for the lab #3:

1) A minimum of 12 people will be in the database. Use constants to define the min values. There is no maximum for Lab #3.

2) Title strings will have multiple words and blanks and no maximum length will be given.

 

 

Problem: The people in your database will be speakers, performers, and entertainers who come to the UT Arlington campus in the 2010-2011 school year. These will include the speakers in the Maverick Speaker Series, such as Bill Nye, the Science Guy, and speakers in the Engineering Speaker Series. This will also include performers brought in by EXCEL and other campus groups. As part of this assignment you will have to find this information on the UTA website to use as test data input to your program.

 

When the user runs your program, they must first enter data. The data they entering will be the speaker information that you have researched to use as your test data. The data entry tasks are

 

¥             Have the user call the program and pass in the name of the input file as a command line parameter if using file input.

¥             Introduce the speaker database to a new user.

¥             Create a struct type to hold the data for a speaker, including a pointer to this struct type.

¥             Create a linked list of structs as the user enters the speaker data.

 

After getting all the input data for the speakers and performers from the user (and storing it in a linked list of structs), you will allow the user to do the following for the menu-driven part of the program:

 

1)   Using the data in the linked list,

       A)  Search for speakers/performers by

              i.     Speaker code

              ii.   Date of speech/performance

              iii. Area of expertise

              iv.  Speaker name

       B)  Calculate

              i.     Cost for purchase of a given number of tickets of a given type

              ii.   Age of the speaker at the time of the speech

              iii.  Length of time from current date to speech date

              iv.  Minimum and maximum ticket receipts for a speaker

       C)  List all the speakers that meet a certain criteria

              i.     In the same series

              ii.   Speakers are from a certain state

              iii. Less than a certain ticket price

       D)  Sort the data by

              i.     Speaker code

              ii.   Speech/performance date

              iii.  Speaker last name

2) Update the data in the linked list of structs–this will take the user to a submenu for doing updates

3) Add new events - this will take the user to a submenu to add a new event to the list

4) Delete events

5) End the program

*     OPTIONAL: Write the program in such a way as to be able to conditionally compile it

              a) with debugging turned on or

              b) with debugging turned off

 

 

 

 

 

Data Description: For lab #3, you will be storing the input data in an linked list of structs. You will have one struct data type to hold all the data for one speaker and then you will dynamically allocate a new struct for each speaker then link them into a list to hold all the speakers.

 

Also for Lab #3 you will declare an enumerated type and an union type. The types are defined below and then variable of these types will be declared as members of the struct type.

 

 

Event paid-or-free – This must be an enumerated type with two values. One of the values should indicate if the event requires paid tickets, i.e. early-bird or regular tickets are greater than $0 cost, and the other value would indicate that the event is free, i.e. both early-bird and regular tickets are $0 cost.

 

Event tickets-or-seats – This union type should hold two possible pieces of data. One piece of data would hold the current number of tickets that have been sold for events that have paid tickets. The second piece of data would be the total number of seats in the event location and this would be the value used when tickets are free to the event.

 

 

 

You must declare a struct data type with members that will hold all of the data elements listed below. Following this first list, the data elements are described by type.

 

1) Speaker code – a number of less than four digits that represents the specific speaker. Each speaker in our system will have a unique code associated with them. The code will indicate that the speaker is part of a particular series (see the series codes at the end of the lab assignment). As an example, Ken Burns is the first speaker in the Maverick Speaker Series so you could code him as 100. You will have to create codes for each possible speaker/performer who can be put in your database and you will have to inform the user what the valid codes are.

 

2a and 2b) Speaker last name and speaker first name – two single words with no blanks and less than 40 characters long each that gives the speakerÕs first and last names. In lab #2 we are using strings for the speaker name but we are making the string input simpler by insuring that each name string is one word, i.e. Mary_Jo Scott is one word for first name ÒMary_JoÓ because there is an underscore instead of a blank.

 

3) Performance date given as day, month, and year – three separate numbers.

 

4) Time of event – given in military time. [If you do not understand Òmilitary timeÓ is then look it up or ASK.]

 

5) Series code – a character representing the series or event that the speaker/performer is part of. The valid series/event codes are:

 

M – Maverick Speaker Series

E – Engineering Speaker Series

D – Engineering departmental sponsored event

C – College of Engineering event including Engineers Week

S – College of Science event

U – University sponsored event including EXCEL activities, Homecoming, etc.

L – Levitt Pavilion concert or event

O – Other

 

6) Ticket costs – a cost in dollars and cents. Ticket cost has two values: early-bird purchase or regular purchase. Tickets can be free.

 

7) SpeakerÕs home state – two letter code using US postal codes or the code NU if the speaker does not live in the US.

 

8) Speaker date of birth given as day, month, and year – three separate numbers.

 

9) Speaker expertise – a character representing the speakerÕs field of expertise. The valid expertise codes are:

 

A - Aerospace Engineering

B - Bioengineering

C - Civil Engineering

P - Computer Science and Engineering

E - Electrical Engineering

I - Industrial Engineering

M - Mechanical Engineering

S - Materials Science and Engineering

O - Other Engineering

Z - Science

L - Liberal Arts

D - Education

X - Business

N - Nursing

R - Architecture

W - Social Work

U - Urban and Public Affairs

G - General

 

10) Event price – a variable of the Event paid-or-free enumerated type. The value of this variable is determined by the program based on the ticket prices that are given.

 

11) Event seats – a variable of the Event ticket-or-seats union type. The value of this variable will be read in but the correct meaning must be determined by the enumerated type value and then the value that is read in must be stored in the correct member of the union.

 

12) Speech title – a string with blanks the gives the title of the speech. The maximum length of the speech title is 128 characters.

 

13) Pointer to another speaker struct. This is the variable that will be the ÒlinkÓ in each struct.

 

 

The format for each piece of data is listed below. You must declare a struct type with member elements as described to hold the data for one speaker, ex. struct speaker. In Lab #3 you will use pointers to keep track of the structs. Structs will be dynamically allocated as needed for each speaker that is read in and each new speaker will be added in the correct location to the current sorted linked list of speakers. This is no maximum number of speakers for Lab #3

 

 

 

Speaker code is a single integer value of less than four digits. Use the hundreds place digit to represent the series. For the first speaker, the speaker code would be read in and error checked. If the value is valid, i.e. it passes error checking, then it is stored in the current dynamically allocated struct, current->spkrcode. Error checking should make sure that the value that is entered is one of the valid values for a speaker code based on the valid codes which your program offered to the user.

 

Speaker first name is a single word of less than 40 characters. In the struct the string can be declared as an array or as a char pointer. The string will be read in with the %s specifier in a scanf statement into a temporary string. The length of the string should be checked using the strlen command. If the string is less that 40 chars in length then it should be copied to the current dynamically allocated struct, current->first. Before copying, make sure that there is space allocated if the struct data member is a pointer instead of an array.

 

Speaker last name is a single word of less than 40 characters. In the struct the string can be declared as an array or as a char pointer. The string will be read in with the %s specifier in a scanf statement into a temporary string. The length of the string should be checked using the strlen command. If the string is less that 40 chars in length then it should be copied to the current dynamically allocated struct. Before copying, make sure that there is space allocated if the struct data member is a pointer instead of an array.

 

Performance day is an integer value. It should be error checked and then a valid day value stored in the current dynamically allocated struct.

Performance month is an integer value. It should be error checked and then a valid month value stored in the current dynamically allocated structx.

Performance year is an integer value greater than 2000 and less than 2050. It should be error checked and then a valid year value stored in the current struct.

 

Performance time is a floating point value in the form HH.MM where HH is the hour value in military time and MM is the minute value. You must error check both the hours and the minutes for validity. If it is valid, it should be stored in the current dynamically allocated structy.

 

Series code is a character value. It must match one of the valid series/event codes. If it is valid, it should be stored in the current dynamically allocated struct.

 

Early-bird Ticket cost is a floating point value. It must represent valid dollars and cents. An event can be free. A valid ticket price should be stored in the current struct.

Regular Ticket cost is a floating point value. It must represent valid dollars and cents. An event can be free. A valid ticket price should be stored in the current struct.

 

State is two character values stored in a two char array inside the struct. You must error check the two-letter state code to make sure it matches a valid US postal code (include Puerto Rico and Guam). If it does not match any US, then it's value should be NU. You may read in the two characters separately in the 2 char array or you may read it in as a string to a temp array and then use strncpy to put the two chars into the struct. The array elements are current->state[0] and state[1]

 

Birth day, month, and year are integers and should be handled the same way as performance date except that the birth date must be at least 10 years in the past.

 

Expertise code is a character value. It must match one of the valid expertise codes. If it is valid, it should be stored in the current dynamically allocated structx.

 

Event price is an enumerated type value of the Event paid-or-free type. Its must be automatically determined by the program any time a ticket price is read in or updated. Ticket prices that are both zero $0 should assign an Event price value of FREE. If either ticket price is non-zero, the enumerated type value should be PAID.

 

Event seats is a union type value of the Event seats-or-tickets type. An integer will be read in for this value. If the value of Event price is FREE then the integer value should be stored in the seats member of the union. If the value of the Event price is PAID then the integer value should be stored in the tickets member of the union.

 

Speech title is a string of up to 128 characters. In the struct the string should be declared as a char pointer. Space for the string should be malloced with a size of 30 chars. The string will be read in with the getline function into current->title. The length of the string should be checked using the strlen command. If the string is greater than 128 chars in length then it should be truncated.

 

 

Lab #3 Initial tasks

              Have the user call the program and pass in the name of the input file as a command line parameter if using file input. :

When the user runs the Lab #3 program the user should call the program with a.out and should include the name of the file containing the input data that could be used with the program, for example, abc1234lab3data.txt. Therefore to run this program the user must enter a.out abc1234lab3data.txt. Later in the program the user may choose to read data from the file or to enter data by single-item or line-of-data method.

 

              Introduce the speaker database to a new user.

For this task your system must provide an introduction/welcome screen to the user. The screen should briefly describe what the system will do. You may have the welcome screen stay up for a fixed period of time or you may let the user press a key to continue on with the program. Make sure you tell the user what to do if you want them to press a key.

 

              Create a struct type to hold the data for a speaker, including a pointer to this struct type.

This data type and the enumerated type and union type should all be declared globally.

 

 

Data-entry phase

 

Input Implementation:

 

The struct data type for events should be defined globally as mentioned previously. The actual speaker variables should be dynamically allocated as needed using pointers and linked into a list that is sorted in order by the speaker number. The lab must allow the user to enter any number of events into the database.

 

For this lab the user may enter any number of speakers. The user should NOT give a count of how many events they are entering. [Note for development: start with a small number of events then increase when program is working well ]. When a new event is ready to be entered your program should

              allocate a new struct,

              then read and store input into that struct in one of the three following ways:

                             Individual data method,

                             line of data input method, or

                             file of lines input method.

Once the data for one event has been read in,

              then the struct should be linked into the speaker list in to order sorted by speaker code number from smallest to largest.

This process continues until there is no more input to be given.

 

 

For Lab #3 the user must enter at least 12 speakers. For Lab #3, you must implement at least two of the following three methods of input but one of your methods MUST be file input. You may implement all three data input methods if desired. The first method will prompt the user for each piece of data individually, the second method will allow the user to input all needed pieces of data about one speaker on one line, and the third method is to read lines of speaker data from a data file. The three forms of the input and the input data file are described below. After getting the count of speakers from the user, the program must ask the user how they want to input the data. Your program must give them at least TWO of the following three choices of methods: Individual data method, line of data input method, or file of lines input method (required). Once the user has chosen the method of input, all the input will be done that way for the current run of the program.

 

 

Individual data method:

The user will enter data for one speaker and then the program must ask the user if they wish to enter another speaker. The user will continue to enter speakers until they tell the program that the data is complete.

 

a.           Ask the user for the speaker code (donÕt forget explain codes for them.) Read in their number, make sure it is a valid code and then store it in the current dynamically allocated struct, i.e. at current->spkrcode. As an example of an explanation, you might tell the user "Please enter Maverick Speaker Series speakers as code 1xx, i.e. Ken Burns = 100, Rick Bayless = 101, etc. Please enter Engineering Distinguished Speaker Series speakers as code 2xx, i.e. Dr. Vincent Poor = 200. É" See the Miscellaneous section at the bottom for all of the speaker codes.

b.          Ask the user for the day of the speech/event. Make sure it is a valid number and then store it in the current dynamically allocated struct.

c.           Do the same for the month and year. Be sure to check for validity of the data. [Note: checking validity where appropriate means to check the value IF there is something to check against. For year there is a range of years to check against. For some items there isnÕt anything to check against for this lab except to make sure the size isnÕt negative.]

d.          Ask the user for the time for the speech in the correct format. Make sure it is a valid hour and minute and then store in the current dynamically allocated struct.

e.           Ask the user for the series code – make sure to give them a list of the series/event codes and abbreviations. Check to make sure it is a valid type. Store this valid character in the current dynamically allocated struct.

f.           Ask the user for the early-bird ticket price for the speech. Make sure it is a valid value and then store in the current dynamically allocated struct. Do the same for the regular ticket price and store it. After you have read in the ticket prices then determine the correct value for Event price and store that as well.

g.          Ask the user for the two letters of the speakerÕs home state abbreviation. Store each in the appropriate character of the char array member of the struct at [index].

h.           Ask the user for the expertise code – make sure to give them a list of the valid codes and abbreviations. Check to make sure it is a valid type. Store this valid character in the current dynamically allocated struct.

i.            Ask the user for the speakerÕs date of birth and check as done for performance date. Also check that birth date is at least 10 years in the past. If valid, store in struct.

j.            Ask the user for the single word first name of the speaker. Make sure to indicate that blanks are not allowed. Read it into a temporary string and check the length. If it is OK, store it into the first name string member in the current dynamically allocated struct.

k.           Ask the user for the single word last name of the speaker. Make sure to indicate that blanks are not allowed. Read it into a temporary string and check the length. If it is OK, store it into the last name string member in the current dynamically allocated struct.

l.            Based on the value of Event price, ask the user either for the number of tickets sold or for the number of seats in the event location. Store the value in the correct member of the union in the current dynamically allocated struct.

m.         Ask the user for the title of the speech. Remember that the title is allowed to have blanks. Use getline to read it into the title string and check the length. If it is too long, truncate it.

 

 

Line of data input method:

Your program may ask the user to enter all the information for one event on the same line. This data would be an integer for speaker code, ints for day, month, and year, chars for series code, the two char state code and the expertise code, floats ticket prices and time, words for first and last name, a number for tickets or seats, and a string for the title. You must tell the user exactly how to enter the line of data. The data for a single speaker/performer will be entered by the user as values on one line as follows {there must be one space only between the values}:

 

> 100 24 9 2010 19.00 M 0.00 0.00 NY L 29 7 1953 Ken Burns 525 An Evening with Ken Burns

 

which represents Ken Burns (code 100) on 24 September 2010 at 7:00pm (19.00 in military time) as part of the Maverick Speaker Series with free early-bird tickets and free regular tickets. He is from New York, his birthday is given as July 29, 1953 and his area is Liberal Arts (since heÕs a filmmaker). There are 525 seats in the venue. The title of the event was "An Evening with Ken Burns"

 

Your program will read the first number and store it in the current dynamically allocated struct, then read and store the day integer into the correct member of the current dynamically allocated struct, then read and store the third number into the correct member, and so on. Your program should read all the numbers and chars and words within a single input command. The title should be read with a separate getline command. Your program should read in one line of data and then ask the user if they wish to enter another line. They may enter as many lines of input for speakers as they wish (no maximum number of speakers).

 

 

File of lines input method

You must implement two options for getting the name of an input file. First, your program must accept a command line parameter for the input file name if desired by the user. Clearly indicate how to use the command line parameters in your e-mail when you turn in your lab assignment including the name of your test data file. Second, your program must allow the user to type in a file name and then read from that file.

 

When your user selects file input as the method of entering data, your program should first check to see if the user entered a file name on the command line. If a valid file name was entered, then the program should ask the user if they wish to use the file name that was entered. The user can choose to use the file name already given on the command line or they can enter the name of another data file to use. Once the input file is determined and has been verified, your program will read the data from the file.

 

You must create at least two data files that contains more than 20 lines of event data and you must read the data from either file. To do this requires creating file variables, opening the file and linking it to the file variable, and then reading the data from the file variable using fscanf and getline in the same way that a line of data would be read from the screen. If the file name was entered from the command line, the validity of the file name must be determined before trying to use the file for input. Basically, the two needed commands to create a file variable, infile, and connect it to your data file, lab3data.txt, are:

 

              FILE *infile; //declares a new file variable to be used

 

              infile = fopen(Òlab3data.txtÓ, ÒrÓ); // connects the variable to your data file for ÒrÓeading

 

The first line of the file will just be a line of data that would be read with fscanf and getline commands very similar to the Line of data input method commands.

 

Linking structs:

For this lab the user may enter any number of events. The user should NOT give a count of how many events they are entering. [Note for development: start with a small number of events then increase when program is working well ].

 

The user will enter data for one event struct and then that struct will be added to the linked list. After that struct is added to the list, then the user can enter data for another struct. This process is the same even if the data is read from a file. The steps for entering the data and building the linked list are:

 

Determine if there is more event data to be entered and if so, your program should

              1) allocate a new struct,

              2) read and store input into that struct in one of the three following ways:

                             Individual data method,

                             line of data input method, or

                             file of lines input method

              3) link the struct into the event list in to order sorted by speaker code from smallest to largest.

Loop back to the top to get the next event

 

The list must be BUILT in sorted order by speaker code. If you build an unsorted list and then sort it into event number order this will deduct points.

 

 

Input verification:

When the user has entered count number of speakers/performers, print out all the input event data in an easily readable form, ex. use a table with headings, or columns with headings or rows with labels. It is strongly suggested that this printing be written as a separate function that can be called at any time in the program to print the current contents of the arrays. It is also suggested that a small function be written which will print the name of a speaker given the speaker code as input. The function could have a switch or a bunch of if statements in it.

 

Menu-Driven Phase

 

Task Description:

 

Once all the data is read into the arrays your program should give the user a main menu with the following choices: (use any number scheme you wish)

A)  Search for speakers/performers by speaker code

B)   Search for speakers/performers by date of speech/performance

C)   Search for speakers by area of expertise

D)  Search for speakers by last name

E)   Calculate cost for purchase of a given number of tickets of a given type

F)   Calculate age of speaker at the time of the speech/performance

G)  Calculate length of time from current date to the date of the speech/performance

H)  Calculate minimum and maximum ticket receipts for a speaker

I)    Find all the speakers in the same series

J)    Find all the speakers that are from a certain state

K)  Find all the speeches/performances that cost less than a given ticket price

L)   Sort the data by speaker code

M)  Sort the data by speech/performance date

N)  Sort the data by speaker last name

O) Update the data in a struct in the array–this will take the user to a submenu for doing updates

P) Add new events - this will take the user to a submenu to add a new event to the list

Q) Delete events

R) End the program

 

The search functions for codes and date should let the user enter a speaker code or date or expertise code and then look through the list to find the first speaker that matches that code/date. Print a sentence stating that matching code/date was or was not found and if found, also print the code and the name of the speaker. For the Lab #3 it is only necessary to return the first speaker that is found as a match.

 

The search functions for last name should let the user enter a speaker name and then look through the list to find the first speaker that matches that last name. Use linear search for the name search. Print a sentence stating that matching name was or was not found and if found, also print the code and the name of the speaker and all the data for the speaker. For the Lab #3 it is only necessary to return the first speaker that is found as a match.

 

The calculate function will ask the user for a number of tickets num and a particular speaker code and will print the total cost for num early-bird tickets and num regular tickets.

 

The calculate age function will determine the speakerÕs age by comparing birth date and speech date.

 

The calculate time-until-speech function will determine the length of time by comparing current date and speech date.

 

The calculate min-and-max tickets function will first check to see if a number of tickets is recorded in the enum and union variables. If so, then the number tickets times the early-bird price is the min receipts and the number of tickets times regular price is the max receipts and these values should be printed. If no number of tickets is recorded, then print a message stating that there is not ticket amount to calculate.

 

The find-all-in-series function should ask the user to enter the desired series code then go through every speaker and print the complete information for all speakers that are part of that series.

 

The find-all-from-state function should ask the user to enter a two-letter state code then go through every speaker and print the complete information for all speakers that have that same state code.

 

The find-all-less-than-cost function should ask the user to enter a ticket cost then go through every speaker and print the complete information for all speakers that have that have tickets equal to or less than that cost.

 

Sort-by-speaker-code should use bubble sort to order the struct array based on the speaker codes from smallest to largest.

 

Sort-by-date should use bubble sort to arrange the struct array in order based on the date of the speech/performance from earliest to latest. Make sure you work out the algorithm for comparing two dates before you try to write the comparison tests for the bubble sort. YouÕll have to use the day, month, and year values to do this.

 

Sort-by-name should use selection sort to order the struct array by speaker last name. Use string functions for comparing the names and remember to compare first names if the last names are identical.

 

The update option should take the user to a second screen to allow them to update information in a struct in the array. This screen should ask for a speaker code or a last name from the user and search for that speaker/performer. Once the correct speaker is determined save its pointer value and give the user a menu of the following options:

 

       o Change speech/performance month, day, or year

       o Change the series

       o Change the two state chars

       o Change one of the tickets

       o Change the time

       o Change birth month, day, or year

       o Change the expertise code

       o Change the first name

       o Change the last name

       o Change the number of tickets or seats (make sure to update the enumerated value if needed.)

       o Change the title

       o Return to main menu

 

For any change the user wishes to make, do the same error checking as in the original data entry section. After each change is made, print all of the speaker info at [index]. [Hint: If you write your data entry section with little functions for each input check then you can reuse them all here.]

 

Add new events to the list:

The add events option should take the user to a second screen to allow them to add information about a new event into the linked list. The user should be allowed to choose whether to enter the new event by individual items or by the line of data method (if both of these are implemented) but NOT by file input. The process to add an event should be just like the process for taking in the events initially. The list should be sorted by speaker code before the new element is added and the new event should be put into the list in sorted order. After the new event is added, print the list.

 

Delete events from the list

The delete option should take the user to a second screen to allow them to indicate the information to delete in the linked lists. This screen should ask for an speaker code from the user and search for that event. Once the correct event is determined, the program should verify again with the user that this is the event they wish to delete. If the user answers yes, the event should be deleted from the list by changing the pointers of the other list elements and then freeing the space of the deleted event. After the event is deleted, print the list.

 

When the user chooses "End the program" from the main menu, print a concluding message and then gracefully end the program.

 

 

Implementation Requirements:

 

WRITE A DESIGN DOCUMENT FIRST. The design must include

 

       a) all the functions you expect to write,

 

       b) brief (one line) descriptions of each function, and

 

       c) some indication of which function calls what other functions.

 

The design document may be written as lines of text or as diagrams (such as a diagram that start with the main function at the top and all others below it) or as some combination of those, but it must include the information listed for a), b), and c) above. Each function should accomplish one main purpose and each function at a lower level should have a more specific purpose than the function that calls it. Be sure to include all the functions that are described in this lab assignment. This design documentation will be turned in for the lab and a design will be required to be turned in for Lab 1 and all later labs. See the website for the DESIGN DOCUMENT due date. It is usually ONE WEEK PRIOR to the lab due date.

 

*** A Lab #3 Design Document must be turned in on time in order for your Lab #3 assignment to be graded. ***

 

 

The program should use the following data structures:

              A user defined struct data type (can use more than one struct type) which contains member elements to hold all the required information for one speaker and a pointer.

              An linked list of these structs to store the data

              Files for data input

              Global CONSTANTS for specific and/or minimum values given in this assignment. Constants can be done with #define or with the const declaration. Examples:

 

                             #define EVENTMAX 10

                             const int EVENTMAX = 10;

 

The program should use the following control structures:

              Function calls to perform tasks

              A while or for loop to read the input data

              Dynamic memory allocation for structs

              If, if-else, nested ifs, or switches to error check and implement the menu options

 

The program should NOT use:

              global variables

              exit

              break (except in a switch)

              continue

any topic not covered in class before the lab DUE date unless approved by the instructor

 

Programming practices:

Comment your code! Use headers as described below, use line comments and use block comments. Line and block comments should explain the meaning of the code. As an example compare the following examples of code with comments:

 

Example 1:

/* Find A by multiplying L times W */

A = L * W;      // A is the product

 

Example 2:

/* Find the area of the rectangle by multiplying length times width of the sides */

A = L * W; // A is area, L is length of one side, W is length of perpendicular side attached to L

 

While Example 1 has comments, the comments do not tell us anything extra about the code. The code itself tell us that A is the product of L*W. In Example 2, the comments are meaningful and explain the goal of the code and the meaning of the variables. Make your comments like Example 2 not Example 1.

 

The program should have a program header which gives, at least, your name, the number of the lab assignment, your class and section, the assignment date, the due date, and a description of the program. If multiple files are used, each file should contain a similar header. See your instructor's website for SPECIFIC instructions about the program header.

 

Each programmer-defined function, i.e. each function you write, should have a function header similar to those used in the examples in the textbook. This header should include at least the function name, the purpose of the function, and its inputs and outputs.

 

The program should be implemented as a set of functions with a main routine and at least one function for menu operations, two for getting input, one for printing, and all of the functions listed for the user choices. You may use many more functions than this but you must use at least this many. The purpose of functions is to divide the problem into small tasks, each one assigned to its own function and then to call the functions from main() or from another function when appropriate. Do not code the entire program in main!

 

The program should perform the following actions in the given order:

              Declare and initialize the variables

              Print a welcome screen for the user that introduces the system

              Get the needed input values from the keyboard or file

              Print the appropriate outputs

              Let the user make additional choices until the user indicates that they are finished.

 

Output requirements:

The program must be run and the output recorded in a script file from OMEGA using the gcc compiler. No Exceptions! If you do not know how to create a script file, it is your responsibility to ask the TA, look for help on the class website, or OIT how to use this function.

 

You must come up with information to use as test data for at least 25 speakers/performers who will be at UT Arlington (or nearby) this year. The speaker name, the series they are part of, the date and time they are speaking, and the ticket price must all be real data. You should look at the speaker bios to determine the speaker's home state and birthday. The information for the Maverick Speaker Series, the Engineering Distinguished Speaker Series, and other speakers and programs sponsored by EXCEL can be found on the University of Texas at Arlington website. See the Miscellaneous section below for links.

 

Testing:

This program must be run with two different sets of test data for the input data. You must create two different data sets and run your program with both of them. I will give you a small amount of sample data at the end of this lab for you to use as a model. You may run your program two times within a single execution or you may execute the program two different times so that you have a total of two different data sets. The sample data sets that you create must meet the guidelines given in the problem definition. Your test runs should demonstrate all the choices that are available in your program.

 

NOTE ABOUT ERRORS:

 

Programs turned in for credit MUST compile and run WITHOUT any compilation errors or runtime errors using the gcc compiler on omega. No other compiler may be used for the compilation for credit. No other operating system may be used for the compilation and/or execution for credit.

 

Compilation errors occur while the program is being developed and they prevent the program from compiling correctly. Programs compile correctly when running

 

>gcc myprogram.c

 

gives no error messages.

 

Programs may be turned in for credit when they are partially complete but all completed functions must run without any errors. A program completes without runtime errors if it ends only when the user selects for the program to end and it correctly prints the exit message. Partially complete programs that run correctly for all implemented menu choices will receive partial credit.

 

Any other type of ending is a runtime error or a "crash". A program has a runtime error if it compiles and runs but then crashes in any situation, i.e. if there is any set of choices the user can make that will make the program crash. It is your responsibility to test all possible choices in your program to make sure that none of them cause a runtime error. The goal of creating input test data and running your program with it should be to test all of the various choices in your program to make sure all of them terminate correctly.

 

Labs which have errors in them and do not terminate normally will receive an overall grade of 0 (zero)

 

 

Lab #3 Grading Scale:

Code:   (47%)

              Program style:

                             Program header and function headers for all functions             (2 points)

                             Comments (line comments and block comments)        (4 points)

                             Modularity (division of the problem into small tasks, each one assigned to its own function and

                                           called from main() or from another function when appropriate --do not code the entire program in main!) (2 points)

                             Style (indentation, consistency, meaningful identifiers, lateral separation of code from line comments, etc.) (2 points)

                             Quality and correctness of code (simplicity, readability, testability, etc.) (4 points)

              Correct definition and use of the struct type including all correct data members (6 points)

              Correct definition and use of the enumerated type including all correct values (2 points)

              Correct definition and use of the union type including all correct data members (2 points)

              Correct manipulation of the linked list (7 points)

              Correct use of required control structures (4 points)

              Correct implementation of files from command line parameters and file variables for input (4 points)

              Correct function structure as required (4 points)

              Proper implementation of data input and input error checking (4 points)

Output:              (53%)

              User clearly understands what is being requested for input (3 points)

              Command line parameter for file name works correctly (2 points)

              File input works correctly (4 points)

              Correct determination of enumerated type value and use and correct use of union value (3 points)

              Initial sorted linked list created correctly from input data (6 points)

              Sort tasks perform correctly on linked list (8 points)

              Search tasks perform correctly (5 points)

              Find-all tasks perform correctly (3 points)

              Calculate tasks perform correctly (5 points)

              Update, add and delete tasks perform correctly (5 points)

              Input verification shows valid values and list of inputs correctly saved and printed (2 points)

              Output gives clear information to explain the values to the user (4 points)

              Output contains all the given test data and one additional data set (3 points)

Grading Deductions:

              Use of global variables will result in an overall grade of 0 (zero) [-100 deduction]

              Use of the exit, break (outside a switch), or continue command will result in an overall grade of 0 (zero) [-100 deduction]

              Labs which have errors in them and do not terminate normally will receive an overall grade of 0 (zero) [-100 deduction]

              Late submission of softcopy of code and/or script file to appropriate TA will result in an overall grade of 0 (zero) UNLESS

                             student has obtained prior instructor approval [-100 deduction]

              Use of C language elements not yet discussed in class by the lab due date will result in potential deduction of points

                             - discuss with instructor before using.

              Missing design document or missing script file or missing C code will result in an overall grade of 0 (zero) [-100 deduction]

 

Miscellaneous:

For Maverick Speaker Series (series code M), number each speaker in order from 100. Therefore Ken Burns is speaker code 100, Rick Bayless is code 101, etc.               http://www.uta.edu/maverickspeakers/index.php

For Engineering Distinguished Speaker Series (series code E), number each speaker in order from 200. Therefore Dr. Vincent Poor is speaker 200, Dr. Cristina Amon is 201, etc.

              http://www.uta.edu/engineering/speakerseries/

Other engineering events with codes D or C should be numbered with codes starting with 300. For example, see http://www.cse.uta.edu/news/seminars/InvitedTalks.asp?pageVer=

University Events (series code U) include concerts. The page at http://www.uta.edu/studentaffairs/universityevents/ue/ will have a listing for a Fall Concert and that performer should be included when available.    University Event speakers or performers should be numbered starting with 400.

College of Science (series code S) speakers would include astronaut Barbara Morgan. This info can be found at https://www.sallyridescience.com/festivals/10uta1030. Number any College of Science speakers starting at 500.

Concerts at Levitt Pavilion (series code L) can be included for speakers/performers. Number these performers starting with 600. http://www.levittpavilionarlington.org/

Number any speakers from series code 0 starting with 700.

 

Format of the data: First line is the data used as an example above. Do not include the comments in your data file (if using a file).

 

100 24 9 2010 19.00 M 0.00 0.00 NY L 29 7 1953 Ken Burns 525 An Evening with Ken Burns

603 4 9 2010 19.30 L 0.00 0.00 TX L 13 11 1946 Ray_Wylie Hubbard 2300 Levitt Pavilion performance // Ray Wylie Hubbard at Levitt Pavilion

501 30 10 2010 13.00 S 20.00 200.00 ID D 28 11 1951 Barbara Morgan 300 Engineering for space //Barbara Morgan at Sally Ride Science Festival

201 5 10 2010 18.00 E 0.00 0.00 NU B 4 1 1960 Dr_Cristina Amon 525 Hierarchical Thermal Transport Modeling and Simulation in Semiconductors from Nano to Macro Scales

/* Dr. Cristina Amon (code 201) on 5 October 2010 as part of the Engineering Distinguished Speaker Series with free early-bird tickets and free regular tickets. She is from Toronto, Ontario, Canada and speaks at 6pm. */