Lab #4 Assignment

CSE 1320-001

Summer 2011

Due Date:             See class website for due date

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

Grade value:          14% 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 covered in Foster and Foster as covered in class.  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 lab will introduce students to Dr. T's approach to lab assignments and to reinforce and refresh previously learned material about C and 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.  The format of this assignment is similar to the assignments that will be required for the rest of the semester so a student who is unsure of their skills can use this assignment to refresh them and to ask the instructor or TA about any concepts they are unsure of. 

 

Topics: 

            Linked lists

            Command line parameters

            Multiple program files

            Testing and test plans

            Pointers

          Structs

            Recursion

            Algorithms

          One-dimensional Array

          Strings

          Control structures

          Functions

          Arithmetic and relational operators

Input and output,

Passing parameters

          Data types

          Global constants

          Pre-processor directives

          Searching

            Sorting

          Program design

          Modular programming structure

          Error checking

          Programming style

          Compiling code,

Executing code,

Debugging and testing.

 

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:  This semester our theme will be working on a support system to manage information for a theater company.  You are going to put together a small database of information to help make show reservations and to handle other aspects of the theater production.  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.   

 

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. You should not need to use any library functions beyond those mentioned in the book and in class.

 

Assumptions for the lab #4:

 

1) A maximum of 15 shows per week are allowed.  Use constants to define the max value.

2) Strings will have a maximum length that will be given.

3) There is no maximum number of shows for Lab #4.

 

Problem:  The data in your database will be information about plays, musicals, dramas, comedies, and other live shows in local theaters, information about the shows and tickets for them, and other data needed regarding the shows.   As part of this assignment you will have to find real data about local theater shows to use as test data for your program.

 

Your program will really be two related parts.  First in the data-entry phase the user is entering all the data needed to find and manipulate the show data.  You can imagine that this user is someone who works for the theaters and is entering all this data.  This will be the first task that happens when someone starts running your program. 

The data they entering will be the theater information that you have researched to use as your test data.  Getting all the input data for the shows from the user and storing it in a linked list of structs, will all happen in the data-entry phase of the program.  After getting all the input data for the shows from the user, your program will then go into menu-driven phase.  This will allow the user to do the following tasks.  These tasks are actions that a theater patron might want to perform:

 

1)          Using the data in the linked list,

          A)          Search for a show by

                    i.          Type of show

                    ii.         Theater location

                    iii.        Date of show

                        iv.        Tickets sold

          B)          Calculate

                    i.          Purchase of tickets for the show and find total cost

                    ii.         Number of times the show will be performed

          C)          List all the shows that meet certain criteria

                    i.          Less than given cost

                    ii.          Before or after a given date

                    iii.         In the same city

          D)          Sort the data by

                    i.          Show code

                    ii.          Show date

                        iii.        Show name

                        iv.        Number of times the show will be performed

2) Update the data in the list-this will take the user to a submenu for doing updates

3) Add or delete shows from the list

4) End the program

 

 

Data Description:  For lab #4, you will be storing the input data in a struct type for a show stored in a sorted singly linked list. The show struct will have two date structs and an array of weekly performance structs in it.  The struct must have at least one internal pointer to use as a link to another struct of the same type.

 

The data members of the show struct type and descriptions are given below.  Following this first list, the data elements are described by type.

 

1) Show code - a four (4) digit integer where the 1000s place represents a city, the 100s digit represents a theater company and the other two digits indicate a specific show.  The guidelines for the city codes and theater company codes are given at the end of the assignment.

 

2) Show name - a string less than 120 characters long that gives the show name.  In lab #4 we are using strings and reading them in with the getline command in order to allow blanks in the string. i.e. Jeeves in the Morning is a show name string

 

2a) Theatre zip code – a 5 digit US zip code giving the zip code of the theatre where the show is playing

 

3) Genre letter code - a letter representing the kind of show.  Choices are:

D Drama

C Comedy

S Suspense

F Fantasy

M Musical

V Variety

R Revue

I One man show

O Any other type of show - such as a special performance

 

4) Show start date as day, month, and year - three separate numbers read into a date struct which is part of the show struct type

 

5) Show end date as day, month, and year - three separate numbers read into a date struct which is part of the show struct type

 

6) Number of shows per week

 

Data for each show per week should be stored in a weekly performance struct that is in an array stored as part of the show struct.

 

6a) Day of show as a letter (for each show in a week)

S Sunday

M Monday

T Tuesday

W Wednesday

R Thursday

F Friday

A Saturday

 

6b) Start time of show (in hours and minutes) - save as a floating point value HH:MM

 

6c) Show designation as a letter

R Regular

M Matinee

L Late showing

 

6d) Cost per adult ticket for this show in dollars and cents - save as a floating point value

 

6e)  Current Tickets sold for this show – kept as a running total

 

6f) Number of adults attending (age 18 or older) – kept as a running total

 

6g) Number of children ages 2 through 17 – kept as a running total

 

6h) Number of infants less than age 2 – kept as a running total

 

 

7) Total number of available seats for the show

 

8) Length of show from start to end in minutes

 

9) Show run – number of performances calculated from previous data

 

 

The format for each piece of data is listed below. 

 

You will declare a struct show type.  This data type will have all the info listed above as data members of the struct.  You will also declare a struct type to hold a date and a struct type to hold the data for one weekly performance.  The show struct will have two date structs in it – one for start date and one for end date.  The show struct will also contain an array of the weekly performance structs.  To store your data for all the different shows, you will allocate structs one at a time, fill them with data, then link them into the sorted linked list of structs.

 

As an example, let's say the user is going to enter data for two shows.  The first show will be to see “Alice Wonder” (code 1310) and the second show will be “The Hobbit” (2108).  For each show you will be asking the user for all the pieces of data listed above and storing this data into the currently allocated show struct .  The different shows, in this case the first show and second show, will be stored in the first and second structs that are created.  These structs should be linked together in order by show code as the data is being read in.

 

To store data in the struct show linked list, you allocate a new struct, assign the data to that struct, then determine where that struct should be linked into the existing list and add it to the linked list in order.  Therefore the show code for  Alice Wonder would be stored in current->showcode and the start day of the show would be current->start.day

 

As you read in the shows, you will NOT be numbering them.

---------------------------------------

Show code - a four (4) digit integer where the 1000s place represents a city, the 100s digit represents a theater company and the other two digits indicate a specific show.  The guidelines for the city codes and theater company codes are given at the end of the assignment.  You will have to validate the 100s place and 1000s place of any code entered by the user.  For the first show, the show code would be read in and error checked.  If the value is valid, i.e. it passes error checking, then it is stored in linked list.

 

Show name - a string with blanks of up to 120 chars in length.  The show name will be read in with getline into a temporary string of length 256.   The length of the string should be checked using the strlen command.  If the string is less that 120 chars in length then it should be copied to current->showname string in the current struct.  showname should be declared as a character pointer in the struct and space should be dynamically allocated for exactly the length of the show name when it is read in.

 

Theatre zip codeˆ- an integer US 5 digit zip code.  You have to validate the length but you do not have to validate correctness of zip codes.

 

Genre letter code - a single character representing the kind of show.  It must match one of the valid codes.  If it is valid, it should be stored.

 

Show start day is an integer value.  It should be error checked and then a valid day value stored in the date struct

Show start month is an integer value.  It should be error checked and then a valid month value stored

Show start year is an integer value greater than 2000 and less than 2050.  It should be error checked and then a valid year value stored

 

Show end day is an integer value.  It should be error checked and then a valid day value stored as appropriate.

Show end month is an integer value.  It should be error checked and then a valid month value stored as appropriate.

Show end year is an integer value greater than 2000 and less than 2050.  It should be error checked and then a valid year value stored as appropriate..

 

Number of shows per week is an integer value.  It should be error checked and then a valid value stored at

 

For each show in a week, the following for data items must be requested and stored:

Day of show is one letter per weekly show.  It should be error checked and then a valid type code stored at

current->weekly[weekshow].doshow  where weekshow indicates which show during the week this is.

 

Show designation is one letter per weekly show.  It should be error checked and then a valid type code stored at

current->weekly[weekshow].desig  where weekshow indicates which show during the week this is.

 

Start time for a show is a floating point value in the form HH.MM where HH is the hours in military time and MM is the minute value.  It should be error checked and then a valid start time stored at current->weekly[weekshow].starttime

 

Cost per adult ticket is a floating point value.  It must represent valid dollars and cents.  The cost of a ticket can be free.  A valid ticket price should be stored in the float array at current->weekly[weekshow].cost

 

Tickets sold is an integer value.  It should be calculated from the number of adult, child and infant tickets selected and kept as a running total as more tickets are purchased.  It should be updated whenever the user chooses to calculate and purchase tickets.  It should also be checked against the available seats number to guarantee tickets are still available. This value should be calculated automatically by your program after a ticket purchase for a show is entered and as the user acts on the data and then stored at current->weekly[weekshow].sold

 

Adult is an integer value. This should be initialized to 0.  It will not be entered until the user reaches the menu functions. It should be error checked and then a valid number of adults stored at current->weekly[weekshow].adult

Child is an integer value.  This should be initialized to 0.  It should be error checked and then a valid number stored

Infant is an integer value. This should be initialized to 0.  It should be error checked and then a valid number stored

 

 

 

Available seats is an integer value.  It will be entered by the user and error checked for a reasonable value. This should be stored in current->seats

 

Show length is an integer value.  It will be entered by the user as a number of minutes.  It must be greater than 15 and less than 1440. This is the length of the entire show and should be stored in current->showlen

 

Show run is an integer value.  It should be calculated from the number of days from the beginning to the end of the show, divided to get the number of weeks and then multiplied by the number of shows per week.  If the number of weeks is a fraction, round up to the next whole number of weeks before multiplying.  This value should be calculated automatically by your program after the data for a show is entered and stored at current->run

 

 

 

Input Implementation:  For Lab #4 the user must enter at least 10 shows.  The program should NOT ask how many shows there are to enter.  The program must loop until the user is finished with input.  The program must ask the user if they wish to continue to read and store input.

 

 

For Lab #4, you must implement TWO of the following three methods of input and you are REQUIRED to implement file input.  In addition to file input you may implement either the individual data method or the line of data method or both.  The three forms of the input are described below. The first question the program must ask the user is how they want to input the data.  Your program must give them at least two choices of methods:  File input (REQUIRED choice), Individual data method, or line of data input method.  Once the user has chosen the method of input, all the input will be done that way for the current run of the program.

 

For Lab #4 you must implement command line parameters to do the following.  If the user has entered any command line parameters other than the executable name, i.e. a.out, then the program should assume that the first parameter after a.out is the name of an input file.  The program should open this file and check to make sure the file pointer is valid.  If it is, the program should read all input from the file.  In this case, the program would NOT ask the user about what kind of data entry the user wants.  The program SHOULD print out a message saying, “You entered file name “Lab4stuff.txt” on the command line.  It will be used for input.”  If the file name is not valid or if there was no command line parameter, then the program should let the user choose any of the implemented input methods listed below including file input.

 

 

Individual data method:

a.          Ask the user for the show 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 struct at the correct location.  As an example of an explanation, you might tell the user "Please enter a show code.  Codes should be four digits with the first digit representing the city, the second digit indicating the theater company and the last two digits just being a unique code…" and then you can list the cities and theater companies for them to use. See the Miscellaneous section at the bottom for the show code info.

a1.        Ask the user for the 5-digit zip code of the theatre.  Check to make sure it is a valid value that could be a zip code.  You do not have to check that it is a real zip code.  Store the zip code in current->zip

b.          Ask the user for the genre letter code and give them the choices. Check to make sure it is a valid type.  Store this valid character in current->genre.

c.           Ask the user for the month, day, and year for the start of the theater show.   Make sure it is a valid date, i.e. it is a real date, and then store it in the start day struct at current->start.day,etc..

d.           Ask the user for the month, day, and year for the end of the theater show.   Make sure it is a valid date, i.e. it is a real date and after the start date, and then store it in the end day struct.

e.          Ask the user how many showings there are per week of this theater show.  Store the number of showings in the integer array at the correct location, current->perweek

f.          For each weekly show,

1.          Ask the user for the day of show letter and give them the choices.  Check that they entered a valid code letter and then store it at current->.weekly[weekshow].doshow    where weekshow indicates which show during the week this is.

2.         Ask the user for the show designation and give them the choices.  Check it and store it as appropriate.

3.          Ask the user for the start time of the show entered as a floating point value representing HH.MM .  Check that the value is positive, that HH is less than 24, and that MM is less than 60.    Store the time  as appropriate..

4.          Ask the user for the cost of that theater show for a regular adult ticket entered as a floating point value representing US dollars and cents (ex. 450.99).  Check that the cost is valid and store  as appropriate..

g.         Ask the user for the number of seats that are available in that theater for that show.  Check and store as appropriate.

h.         Ask the user for the length of the show in minutes.  Check and store as appropriate.

i.          Ask the user for the name of the show.  Read it into a temporary string and check the length.  If it is OK, store it into the name string in current->.showname.

 

 

Line of data input method:

Your program may ask the user to enter all the information for one show on the same line.  This data would be an integer for show code, ints for day, month, and year of start and end along with counts of weekly shows, seats, minutes, and attendees, chars for genre code, day and designation, floats for ticket cost and start time, and a string for the name.  You must tell the user exactly how to enter the line of data. 

The data for a single show will be entered by the user as values on one line as follows {there must be one space only between the values}.  Here's an example:

 

> 1310 76102 C 5 27 2011 6 26 2011 5 R R 8.00 20.00 F R 8.00 25.00 A M 3.00 15.00 A R 8.00 25.00 S M 3.00 15.00 150 165 Alice Wonder

 

which represents the show “Alice Wonder” (code 1310, name Alice Wonder) in zip code 76102 from May 27. 2011 to June 26, 2011 with five shows per week.  The weekly shows are Thursday regular show at 8pm for $20, Friday regular show at 8pm for $25, Saturday matinee at 3pm for $15, Saturday regular show at 8pm for $25, and a Sunday matinee at 3pm for $15.  There are 150 seats available and the show is 165 minutes long. 

 

And a second example:  [NOTE: this example is shorter because the show has less weekly performances]

 

> 2108 76010 F 7 1 2011 7 10 2011 4 F R 7.30 10.00 A M 2.00 8.00 A R 7.30 10.00 S M 2.00 8.00 200 120 The Hobbit

 

which represents the show The Hobbit  (code 2108, name The Hobbit) in zip code 76010 from July 1. 2011 to July 10, 2011 with 4 shows a week.  The weekly shows are Friday regular show at 7:30pm for $10, Saturday matinee at 2pm for $8, Saturday regular show at 7:30pm for $10, and a Sunday matinee at 2pm for $8. There are 200 seats available and the show is 120 minutes long. 

 

Your program will read the first number and store it at the correct location, then read and store the character into the corresponding location, then read and store the third number (month) into the struct, and so on.  Your program should read all the numbers, chars, and the string within a minimum number of input commands. (Probably three scanfs and a getline is minimum) Your program should read in as many lines of input for shows as were originally specified by the count up to the maximum of 12 lines of input (shows). 

 

 

File input method:

Your program may ask the user to enter all the information for all the shows from a file.  The file would have one show per line.  The data for one show in the file would be exactly the same data you would use for line of data input. 

 

You must create a data file that contains at least 7 lines of show data and you must read the data from the 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 user chooses file input, then your program must first get the name of the input data file to use.  This can be done in two ways:

 

1) You may tell the user to name the file a specified name, i.e. "You input data file must be named lab3data.txt in order for the program to use it.  The file must be stored in the same directory as the program.  Press any key when your file is ready to be read. " You would then accept a key press from the user, set up the file pointer for the file, and then begin reading from the file one line at a time.  As one line of data is read, it should be error checked before the next line is read.  You would loop until you reach the end of the file.

 

2) If you wish to give the user more flexibility, you can let the user type in a string with the name of the file in it and then use the string as the file name to set up the file pointer.  You would read in the name string using getline in the same way you read in the show name.

 

For either approach your program needs a FILE * pointer which is connected to the file with fopen.  Ex:  Using the 2nd method above:

int filenm = 100;         // not needed for 1st method

char *filename;            // not needed for 1st method

FILE *infile;

 

printf("Please enter the complete name of your data file:  "); // use different message for 1st method above

getline(&filename, &filenm, stdin);                                        // not needed for 1st method

if (filename != NULL)                                                                        // not needed for 1st method

            infile = fopen(filename, "r");                                       // infile = fopen("lab3data.txt","r"); for 1st method

 

 

 

Input verification:

When the user has entered count number of shows, print out all the input show 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 linked list.  It is also suggested that a small function be written which will print the name of a show given the show code as input.  The function could have a switch or a bunch of if statements in it.

 

 

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 show by show designation

B)          Search for show by start date of show

C)          Search for show by city

D)          Search for show by number of tickets sold

 

E)          Purchase of tickets for theater show and calculate cost

F)          Calculate maximum revenue for a show

 

G)          Find all the shows in the same city

H)          Find all the shows that are shorter than a given length of show in minutes

I)          Find all the shows that cost less than a given amount

 

J)          Sort the data by show code and print the sorted shows

K)          Sort the data by show start date and print the sorted shows

L)          Sort the data by show name and print the sorted shows

M)          Sort the data by number of times the show will be performed and print the sorted shows

 

N)           Update the data in the arrays-this will take the user to a submenu for doing updates

O)        Add a new show to the linked list

P)         Delete a show from the linked list

Q)           End the program

 

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

 

The search for theatre location should let the user enter a city code OR a zip code.  If a city code is entered, the program should  return the first show that is found as a match.  Note that the city search will have to look at the show code city digit for this search.  If the zip code is entered, the search should find the zip code that is the closest numerically to the entered code and the closest show should be returned.  If two shows have the same zip, choose the one with cheapest ticket prices.

 

The search by start date should use linear search to find the given start date.   Print a sentence stating that matching date was or was not found and if found, also print the code and the name of the show.  Remember that to do binary search, the array must be sorted first.

 

The search by tickets sold function should let the user do one of the two following things:

            i.          Enter a maximum number of tickets and find the show with the value closest and less than that max or

            ii.         Enter a number and find the show with the CLOSEST number of tickets either greater or less than the given number

When the show is found, print the show name and code at least.

 

The purchase tickets function will allow the user to enter a number of adult, child, and infant tickets to purchase for a particular weekly showing of a show.  These values should be used to calculate the cost of the ticket purchase as described below.  These values should also be used to increment the amounts of adult, child and infant tickets show for that weekly showing.  When these value are incremented, total tickets sold should also be incremented.  If the purchase of these tickets would exceed the number of seats, give the user  message and do not update the amounts of adult, child and infant totals.  To calculate cost, the function will ask the user for a particular show code from those in the database (print the table of shows) and will then calculate and print the total cost of the requested tickets for all the attendees requested by the user.  The cost of any show is calculated as follows:

The show cost for one adult is the ticket cost for that show.

The show cost for one child is equal to the three quarters of the adult show cost.

The cost for one infant is half of the child cost.

The total cost of a show for all attendees is the number of adults times the adult cost plus number of children times the child show cost plus number of infants times the infant cost.

After total cost is calculated, print total cost for this purchase and print total number of seats sold out of a total number of available seats.

 

The calculate-maximum revenue will be  calculated as the sum of all the adult show costs for each show times the number of available seats.  

 

The find-all-in-city function should ask the user to choose the desired city from a list then go through every show and print the complete information for all shows that are in that city.  You will have to use the show code to determine this.

 

The find-all-shorter-shows function should ask the user for a number of minutes and then go through every show and print the complete information for all shows that have a total length of show time shorter than the given theater time. 

 

The find-all-less-than-cost function should ask the user to enter a show cost for one adult then go through every show and print the complete information for all shows that have that have a single adult cost equal to or less than that cost.

 

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

 

Sort-by-date should use bubble sort to arrange the array in order based on the date of the start of the show 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-show-name should use bubble sort (given in the book) to order the struct linked list based on the names of the shows.  Use the string comparison function for this.

 

Sort-by-number-of-performances should use bubble sort (given in the book) to sort from highest to lowest.

 

The update option should take the user to a second screen to allow them to update information in the arrays.  This screen should print the shows in the database for them to choose from, ask for a show code from the user, and search for that show.  Once the correct show is determined save its [index] and give the user a menu of the following options:

 

          o   Change show start or end month, day, or year at [index]

          o   Change the number of attendees at [index]

          o   Change the genre letter code at [index]

          o   Change the name at [index]

          o   Change the number of shows per week at [index]

          o   Change the weekly show info at [index] – Note that you must do this automatically if the user increased the number of weekly shows.

          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 show info.   [Hint:  If you write your data entry section with little functions for each input check then you can reuse them all here.]

 

The add function should allow the user to create a new show struct, fill it with data, and put it in sorted order in the linked list.  After each change is made, print all of the show info.

 

The delete function allows the user to specify a show to remove and then remove that from the list.  After each change is made, print all of the show info.

 

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 #4 Design Document must be turned in in order for your Lab #4 assignment to be graded.

 

For Lab #4 you must also write and turn in a TESTING PLAN along with your design document.  The testing plan should include at least five (5) sets of test data values that will test at least the following elements of your code:

            Test the data entry number validation for day, month, year

            Verify the length of a show name

            Demonstrate correct calculation of total tickets sold for a show

            Demonstrate correct sorting of the linked list

            Demonstrate a search that does NOT find a matching value

Give your set of test values for each test element above and indicate what the correct result of the test should be and how to demonstrate that this result has occurred, i.e. will the user have to ask for the data to be printed out or will that happen automatically?

 

The program should use the following data structures:

          struct data types for a show, a date and weekly show information

            an array of type struct show

          Global CONSTANTS for specific and/or maximum 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

          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!

 

For Lab #4, you must split your program into at  least three separate program files as follows:

            All constants and type definitions in one file,

            The main routine and the functions prototypes in one file, and

            The remaining functions in one or more physical files.

Compile them all together  with include statements or with gcc to create the output a.out

 

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 ask OIT how to use this function.

 

You must come up with information to use as test data for at least 15 shows. You may only have one show that is a single weekly showing - all other shows must have multiple weekly showings.  Please use real data for shows and costs.  Feel free to use theater websites to "plan" the show data for this lab.  (There is a great starting point at http://www.dfwonstage.com/ ) See the Miscellaneous section below for other useful info.

 

Testing:

This program must be run with the different sets of test data as given in your test plan for the input data.  You must create different data sets and run your program with 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 multiple times within a single execution or you may execute the program different times so that you have 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 and warnings occur while the program is being developed and they prevent the program from compiling correctly. Programs compile correctly when running

 

>gcc myprogram.c

or

>gcc mymainprogram.c myheader.h myfunctions.c

 

gives no error or warning 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 compile and 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)

 

 

Grading Scale:

Code:  (41%)

            Program style:

                        Program header and function headers for all functions          (1 point)

                        Comments (line comments and block comments)      (1 point)

                        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!)  (1 point)

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

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

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

            Correct definition and use of external struct pointers (3 points)

            Correct manipulation of the linked list  (9 points)

            Correct use of required control structures  (4 points)

            Correct implementation of files and file variables for input (3 points)

            Correct function structure as required (3 points)

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

            Correct use of command line parameters (2 points)

            Correct use of multiple files for compilation (2 points)

Output:              (53%)

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

            File input works correctly (4 points)

            Initial sorted linked list created correctly from input data (8 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 tasks perform correctly (4 points)

            Add and delete tasks perform correctly (4 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 file data output and keyboard entry output (3 points)

Test Plan and testing in script file (6%)

            Test plan contains required number of unique test values  (2 points)

            Test plan gives tests for each of the minimum required code elements (2 points)

            Test plan outlines how to test for correctness of required code elements (2 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 cannot be compiled or do compile with warnings will receive 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]

 

          Missing design document will result in an overall grade of 0 (zero) [-100 deduction]

          Missing test plan will result in 50 point deduction [-50 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.

 

 

Miscellaneous:

 

Show code structure:  The code will be a 4-digit number.  The leftmost digit (1,000s place) will indicate the city as follows:

1 Fort Worth

2 Arlington

3 Dallas

4 Irving

5 Plano

6 Garland

7 Grand Prairie

8 Carrollton

9 Other DFW city

 

 

Following the city value will be a value in the 100s place that indicates one of the theater companies below.  The codes for that digit will be:

1 Theater Arlington

2 Casa Mañana

3 Jubilee Theater

4 Stage West

5 Dallas Theater Center

6 Garland Civic Theater

7 Hip Pocket Theater

8 Kitchen Dog Theater

9 ICT MainStage

0 Any other theater company in DFW area

 

Therefore, a show code for “Alice Wonder” might be 1310 for Fort Worth, Jubilee Theater, show #10.  Likewise “The Hobbit” might be 2108 for Arlington, Theater Arlington, show #8. 

 

Sample data:

1310 76102 C 5 27 2011 6 26 2011 5 R R 8.00 20.00 F R 8.00 25.00 A M 3.00 15.00 A R 8.00 25.00 S M 3.00 15.00 150 165 Alice Wonder

2108 76010 F 7 1 2011 7 10 2011 4 F R 7.30 10.00 A M 2.00 8.00 A R 7.30 10.00 S M 2.00 8.00 200 120 The Hobbit