Lab #3 Assignment , CSE 1320 Spring 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) added to total of lab grades.

 

Topic objectives:     Linked lists                                        Bit fields

                                    Unions                                               Enumerated types

                                    Conditional compilation                Recursion

                                    Modular programming structure Program design

                                    Error checking                                  Programming style

                                    OPTIONAL for Extra Credit: Conditional compilation, Command line parameters

 

The goal for this lab is to extend the design and development of structs for data representation and to manipulate linked lists of structs.  This lab will use strings and file input.  This lab will have you create a new simple recursive function as well.  As in Lab #2 you will be required to create a design document and turn it in prior to the due date of the lab.  All material that has previously been covered may also be used in this lab.

 

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.

 

* -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * -- * --

 

As a student as a large university you have many activities and events that you can choose to attend. These events give you an opportunity to expand your worldview and learn things outside the classroom. However, there are so many of these events that it can be difficult to keep track of all of them. Your goal for this program will be to develop a computer program that helps students learn about events that are occurring on campus that they may wish to attend. This system will be a searchable calendar and database of upcoming events with categories of event types, event purpose and other info. Your system will have two main activities - first, a knowledgeable user, such as someone who arranges campus events, will input the event data to your system. Once this is done, the system will then become an information provider that a participant user would access to try to find interesting events to participate in.  For Lab #3, the participant user may also add new events to the system and delete existing events as well.

 

Throughout the course of this semester you will work on your event database. Each lab assignment will build on the previous assignments and will also implement changes to make the system more efficient and so on. For this lab you will be modifying components of the event database and changing how they are stored and accessed. You will implement a program that can hold data about events such as event name, purpose, event time, and so on. You will write functions that can retrieve data that matches certain criteria, that can modify the data, that can sort the data, that can output the data, and other tasks.

 

The tasks for this lab assignment will be:

 

*      Introduce the event database to a new user.

 

*      Define a struct data type to hold all the information about a campus event with some new elements added

 

*      Create a sorted linked list of the structs as the data is read in to populate the structs.

 

*      Create and display a screen menu of the following choices for the user.

 

 

1) Using the data in the linked lists,

A) Search for events by

i. Event type

ii. Event goal

iii. Date

iv. Event name

v. Cost

vi. Venue

B) Count how many events

i. Have a user-specified purpose

ii. Cost more than a given amount

iii. Occur in a certain venue

C) List all the events that meet a certain criteria

i. Size

ii. Occur on the same day

iii. Less than a given cost

D) Calculate

i. Cost to attend all events

ii. Average cost of an event

iii. Average event length

iv. Data for the event goal

E) Sort the events according to

i. Event type

ii. Date

iii. Event name

iv. Cost

F) Predict

        i. Event receipts

        ii. Event attendance

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

3) Add new events to the list

4) Delete items from the list

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

 

 

Each of these tasks is described in more detail below. There are also a number of simplifying assumptions for this lab. Many of these simplifications will be eliminated in later labs.

 

Simplifying assumptions for the lab:

a) Various constants will be given for use in the lab. These constants should be declared in your program using "const" or "DEFINE"

b) All events take place on the UTA campus. Later labs may not use this assumption

c) All events will have a unique number and a unique name. Names will be strings but the strings have a max length of 75 characters.

d) Your program must check data VALUES at input but not data TYPES.  The user is responsible for putting in the correct data type as long as your program clearly tells the user what to do.  If the use inputs the wrong type (char when int is required), then this type of error is NOT counted as an execution error in your program.

 

Task Descriptions:

 

*      Introduce the event 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.

 

*      Define a struct data type to hold all the information about a campus event with some new elements added

 

For the lab, the following data will be used:

 

1. Number representing the event

 

2. Name of the event

 

3. Event type. Specifies the form of the event to occur. The following are the valid event types:

C     Concert

S      Spectator

P      Participatory - Competitive

N     Participatory - Non-Competitive

D     Dinner

L     Lunch

B     Breakfast

O     Other

 

4. Purpose of the event. The purpose must be one of the following as denoted by the letter preceding it:

F - fun and social event

M - fine arts event; music, dance, art, theatre, comedy, and other types of arts activities

C - cultural; offers support and education related to a specific culture or group of cultures

S - sports; opportunities to play or support teams

V - volunteer event that does service activities of any type

L - leadership; opportunities for leadership on campus or learning skills for leadership

E - educational; offers some discipline-related content for student

A - academic; offers some sort of academic focused purpose such as tutoring, mentoring, study group, etc.

P - professional; focused on providing support to student for future professions

O - other

 

5. Event time consisting of

a. time of day given as hour and minute in military time (24 hour time)

b. day of the month given as a number

c. month given as a number

 

6. Size. Gives maximum number of event participants

 

7. Cost. Gives cost to participate/ attend event

 

8. Venue consisting of

a. building abbreviation

b. room number or name inside the building

 

9. Length. Gives length of event in minutes

 

10. Event goal. The goal of the event will be one of the following:

        Social networking

        Recruiting

        Charitable fund-raising

        General fund-raising

        Talent demonstration

        Community service

 

11. Goal targets.  The goals above have various targets associated with them:

        for recruiting the target is number of new members

        for either type of fund-raising the target is an amount of money

        for community service the target is number of person hours of service

        for talent demonstration the target is a letter grade

        for social networking the target is number of participants

 

12. Previous attendance.  The number of people who attended this event (or a very similar event) the last time it was held.  For a completely new event, enter -1 for this value.

 

For this lab, the data above for ONE event will be stored in a struct.  The struct data type must be defined to hold all the pieces of data above for an event.  Details for the data are given below:

 

o Event number - the integer numeric code associated with a specific event. For this lab we will have a fixed set of events that are coded by number (ex. One Mike Stand = 842, Wheelchair Basketball Game = 110, FLOC Movie Night = 500, etc.) and that list would be displayed in the output as described below.

 

o Event name - the name associated with a specific event. For this lab we will have a fixed set of events that have names that are strings.  The strings may have multiple words. (ex. One Mike Stand = 842, Wheelchair Basketball Game = 110, FLOC Movie Night = 500, etc.)  The name string is allowed to have a maximum of 75 characters

 

o Event type - the character code of the event type. Make sure that the character that is entered is valid, i.e. that it is one of the allowed characters.

 

o Event purpose - the character code of the purpose of the associated event. Make sure that the character that is entered is valid, i.e. that it is one of the allowed characters.

 

o Event hour and minute - the hour and minute info for the associated event. The hour and minute value will be entered as a single floating point number with the hour value to the left of the decimal and the minute value to the right of the decimal HH.MM . The value should be entered as military time, i.e. 24-hour clock instead of 12-hour clock. Make sure that the event hour and event minute that is entered are valid.

 

o Event daya bit field for the date of the day of the of the associated event. Make sure that the number that is entered is valid, i.e. that it is a meaningful date for that month.

 

o Event month - a bit field for the month info for the event. Make sure that the event month that is entered is valid, e.g. how many months are there in a year?

 

o Event maximum size - the maximum number of people that can attend or be involved in the associated event.

 

o Event cost - the amount it costs to participate in the associated event. Make sure this amount is not negative but it can be free to participate.

 

o Event building – this should be the abbreviation used on UTA maps for a given building on campus.  Determine the appropriate data type for this and declare it.

 

o Event room – this room designation in the building listed above.  This should be a ONE WORD string in order to allow for things like “LoneStarAuditorium” or “229”or “143B” as room designations.

 

o Event length - the expected length in minutes of the associated event.

 

o Event goal – an enumerated type giving constant values representing the six kinds of goals.  By default, any event has the goal of social networking if no other kind of goal is specified and social networking should have an enumerated type value of zero (0).

 

o Event goal target – a union containing the five different possible targets associated with the six goals.  The fund raising target value should be a floating point, the grade target should be single character, and the other targets should be integers.

 

o Event previous attendance - the number of people that attended or were involved in the associated event (or a similar event) the last time it was held. If the event is brand new, enter -1 for this value.

 

All of these data items should be declared as members of the event struct.

 

*      Create a sorted linked list of the structs as the data is read in to populate the structs.

 

The struct data type for events should be defined globally.  The actual event variables should be dynamically allocated as needed and linked into a list that is sorted in order by the event number.  The lab must allow the user to enter any number of events into the database.  When data is being input directly by the user (the individual data or line of data methods), the program should ask the user after each event whether they wish to continue entering data or not and stop when directed by the user.  For the file input, the program should stop reading new events when it reaches the end of the file.

 

For the lab, you must implement at least two of the following three methods of input and one of the methods must be file input. The first method will prompt the user for each piece of data about an event individually, the second method will allow the user to input all needed pieces of data about one event on one line, and the third method is to read lines of event data from a data file. The three forms of the input and the input data file are described below.

 

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 ].  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, the struct should be linked into the linked list of events in to order sorted by event number from smallest to largest.

 

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

 

Individual data method:

 

a. Ask the user for the event code (don't forget to supply a list of names and codes for them.) Read in their number, make sure it is a valid code and then store it in the struct linked list, for example called eventcurr,  at location eventcurr->eventcode

 

b. For the data values that are letter codes (Event purpose, Event type), ask the user for the data using the single character descriptions (don't forget to supply a list of abbreviations for them.) Read in their char, make sure it is a valid abbreviation and then store it in the correct member of the struct .

 

c. Ask the user for the hour and minute that the event occurs. Make sure that the hour and minute values are valid and then store it in the  correct member of the struct .

 

d. Ask the user for the day that the event meets. Make sure it is a valid number and then store it at location eventcurr->eventday

 

e. Do the same for the event month and event size. 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 meeting hours there is a clock to check against. For group size, there isn't anything to check against for this lab except to make sure the size isn't negative.]

 

f. Ask the user for the cost of participating in that event. Make sure it is a valid value and then store it in the  correct member of the struct at index.

 

g. Ask the user for the building abbreviation. Read it into the correct member of the struct.

 

h. Ask the user for the room of the event. Read it as a string into a temporary array and check the length. If the length is OK, copy it into the  correct member of the struct.

 

i. Ask the user for the expected length in minutes of the event. Make sure it is a valid value and then store it in the  correct member of the struct in the list.

 

j. Ask the user to indicate the goal of the event.  Use the meaning of the enumerated type values to give the user choices and then save the user’s input into the correct member of the struct.

 

k. Based on the enumerated type, ask the user for the goal target value and then store that in the union member of the struct.

 

l. Ask the user to enter the number of people who attended this event the last time it (or a very similar event) was held.  Check the validity of the value and store it.

 

m. Ask the user for the name of the event. Read it as a string into a temporary array and check the length. If the length is OK, copy it into the correct member of the struct.

 

When all the data for one event is entered, the event struct must be added to the ordered linked list. 

 

 

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 event code, chars for purpose and type, a float for hour and minute, ints for event day and month and size,  a float for cost, the building abbrevation, one word for the room designation, and a string for the name. You must tell the user exactly how to enter the line of data. The data for a single event will be entered by the user as values on one line as follows {there must be one space only between the values}:

 

> 842 M C 20.00 15 2 250 10.00 UC RosebudTheatre 90 0 100 75 One Mike Stand

 

which represents event 842 (One Mike Stand) on Feb. 15, with a maximum of 250 attendees. It is a fine arts concert starting at 8:00pm and lasting 90 minutes. It costs $10.00 and is located in the University Center, Rosebud Theatre.  The event goal is social networking with a target of 100 people involved and 75 people attended the last One Mike Stand event.

 

Your program will read the first number and store it in correct member of struct (ex. eventcurr->eventcode), then read and store the purpose code into the corresponding character member  of struct , then read and store the third input into its member of struct , and so on. Your program should read all the numbers, chars and single words within a single input command. You may read the string in the same scanf command (hard to do) or in a separate command getline.   When all the data for one event is entered, the event struct must be added to the ordered linked list. 

Your program should read in lines of input until the user indicates that they are finished entering data (events).

 

File of lines input method:

 

OPTIONAL: You may accept a command line parameter for the input file name if desired.  Implementing a command line parameter for file name will be worth up to 2% extra credit.  Make sure if you do this, that you clearly indicate how to use the command line parameters in your e-mail when you turn in your lab assignment. 

 

You may create a file that is any length and you may read the data from this 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 in the same way that a line of data would be read from the screen. Basically, the two needed commands to create a file variable, infile, and connect it to your data file, lab2data.txt, are:

 

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

 

        infile = fopen(“lab2data.txt”, “r”);  // connects the variable to your data file for “r”eading

 

Since the file will NOT have a count in it then 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.

 

 

 

Input verification:

 

When the user has entered count number of events, 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 linked lists.

 

*      Create and display a screen menu of the following choices for the user.

 

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

 

1) Using the data in the linked lists,

A) Search for events by

i. Event type

ii. Event goal

iii. Date

iv. Event name

v. Cost

vi. Venue

B) Count how many events

i. Have a user-specified purpose

ii. Cost more than a given amount

iii. Occur in a certain venue

C) List all the events that meet a certain criteria

i. Size

ii. Occur on the same day

iii. Less than a given cost

D) Calculate

i. Cost to attend all events

ii. Average cost of an event

iii. Average event length

iv. Data for the event goal

a.       Fund-raising

b.       People

c.        Service hours

E) Sort the events according to

i. Event type

ii. Date

iii. Event name

iv. Cost

F) Predict

        i. Event receipts

        ii. Event attendance

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

3) Add new events to the list

4) Delete items from the list

5) End the program

 

 

Function descriptions:

 

Search:

The search functions for type, purpose, date, name, venue, and goal should let the user choose the event type or event date or purpose code or name or venue and then look through the list to find the first event that matches that type, then print a sentence stating that matching type/date/purpose/name/venue was or was not found and if found, it should also print the code, the name, the month, and the day of the event.   These functions may use any algorithm to search.  Note that the search by date must use month and day to find the correct event.

 

The search function by cost should NOT use the binary search algorithm.  It should look at the linked list and use the search algorithm to find the first event that matches the given cost.  It should the print a sentence stating that matching cost was or was not found and if found, it should also print the code, the name, the month, and the day of the event.

 

Count:

The count function should let the user choose a purpose code or a cost or a venue and then go through the data and count (#) how many events have that purpose or are greater than that cost or occur at a given venue. The output should be a sentence stating that the number of events with that purpose or number of events more than that cost or number of events at that location is #.

 

List:

The size list functions should let the user choose a size value and then should print all the events that have a maximum of that size or smaller. Make sure to print a message at the top of the list explaining what is being printed.

 

The list events on the same day function should let the user choose a date (month and day) and then should print all the events that occur on that day. This one is a little tricky in that both month and day have to be checked. Make sure to print a message at the top of the list explaining what is being printed.

 

The list events that cost less is similar to the size list function.

 

Calculate:

The calculate function simply goes through and sums up all the costs for all the events. Print this sum with a message.

 

The average cost function should use the sum function and the total number of events to get its result. Print this average with a message.

 

The average length function should use the sum function and the total number of events to get its result. Print this average with a message.

 

Calculate event goal data:

The fundraising target function should use the weighting fractions given below as the part of cost that goes to fund raising per ticket multiplied by cost and the predicted attendance to get its result. The formula is weight * cost * predicted attendance.  The weight is 80% or .8 for the charitable fundraising and 50% or .5 for the general fundraising.  Print this target with a message.  This function must call the predicted attendance function or take in its value as a parameter.

 

The people target function should determine the target for either new members or total participants as follows.  The total participants target should be the predicted attendance times 110% for an increase of 10%.  The new members target should be 5% of the predicted attendance.  This function must call the predicted attendance function or take in its value as a parameter.

 

The service hours target value should be the predicted attendance times 2 hours. This function must call the predicted attendance function or take in its value as a parameter.

 

 

Sort:

The sort events by date functions should use the bubble sort algorithm to put the list in order by date. The sort by date is the most challenging sort because it requires looking at the month and the day to sort.

 

The sort events by cost function may use any sort function to put the list in order by the cost.  OPTIONAL: Using the recursive merge sort algorithm to put the list in order by the cost will be worth up to 3 points extra credit for the lab.

 

The sort events functions may use any sort algorithm to put the list in order by the appropriate thing, either by type, by name.

 

Predict:

The predict event receipts function is determined using the recursive algorithm below.  It needs to call the function that predicts attendance so make sure that is implemented or stubbed in a useful way.  The idea of the recursive function below is that for the first half of the predicted attendance you’ll assume that all of them show up so you get 100% of the money they will spend to attend.  As you get to higher levels of predicted attendance, you’ll assume less of them show up so you get less money.  Your algorithm stops when either a) the predicted attendance number is 0 or b) the percentage that will show up reaches 0%.  The predict event receipts function should take two inputs – the predicted attendance, the percentage of cost to use (this is always 100% for the start), and the cost to attend the event.  The recursive algorithm is then:

 

As long as the number of predicted attendees is greater than zero (0),

then for half (50%) the number of predicted attendees,

the receipts are 100% of their cost to attend + whatever remaining predicted receipts are calculated

As long as there are still attendees

then call the function again

with half of the current number of predicted attendees,

with the percentage of cost – 10%, and

with the same cost.

Example:

If the function is called with 25 as the predicted attendance and $2 as the cost (and 100% for percentage of cost),

Then half (50%) of predicted attendees (25) is 12, cost is $2 per, and each gives 100% plus

Half of what is left (12) of predicted attendance is 6, cost is $2, and each gives previous percentage -10 (90%) +

Half of what is left (6) is 3, cost is $2, each gives 90% - 10 (80%) +

Half of what is left (3) is 1, cost is $2, each gives 80% - 10 (70%) +

Half of what is left (1) is 0.  The results are then calculated and returned as

1 * $2 * 70% = $1.40 +

3 * $2 * 80% = $4.80 +

6 * $2 * 90% = $10.80 +

12 * $2 * 100% = $24.00  for a total of $41.00 predicted receipts.

 

 

 

The predicted attendance function is a calculation based on the type, purpose, and goal of the event, the size of the venue, and the previous attendance as follows:

 

If the event type is concert, spectator or other,

        Then if the event purpose is fun, fine arts, cultural, or sports

                Then if the goal is fund-raising (either) or community service,

                        Then predicted attendance is 120% of previous attendance or 75% of venue size if this is a new event.

                Else if the goal is recruiting, talent demonstration, or social networking,

                        Then predicted attendance is 105% of previous attendance or 45% of venue size if this is a new event.

        Else if the event purpose is volunteer, leadership, educational, academic, professional, or other,

                        Then predicted attendance is 103% of previous attendance or 40% of venue size if this is a new event.

 

Else if event type is participatory (either kind),

        Then if the event purpose is fun, sports, or volunteer,

                Then if the goal is recruiting, community service, or social networking,

                        Then predicted attendance is 110% of previous attendance or 60% of venue size if this is a new event.

                Else if the goal is fund-raising (either), or talent demonstration,

                        Then predicted attendance is 105% of previous attendance or 45% of venue size if this is a new event.

        Else if the event purpose is fine arts, cultural, leadership, educational, academic, professional, or other,

                        Then predicted attendance is 108% of previous attendance or 50% of venue size if this is a new event.

 

Else if event type is meal (any),

        Then if the event purpose is fine arts, cultural, sports, volunteer, or other,

                        Then predicted attendance is 140% of previous attendance or 85% of venue size if this is a new event.

        Else if the event purpose is fun, leadership, educational, academic, or professional,

                Then if the goal is community service, or social networking,

                        Then predicted attendance is 118% of previous attendance or 65% of venue size if this is a new event.

                Else if the goal is recruiting, fund-raising (either), or talent demonstration,

                        Then predicted attendance is 108% of previous attendance or 50% of venue size if this is a new event.

 

 

List all:

The list events function is the same as the print function described for input verification.

 

Update:

The update option should take the user to a second screen to allow them to update information in the linked lists. This screen should ask for a event code from the user and search for that event. Once the correct event is determined save a pointer to it and give the user a menu of the following options:

 

Change one of the items below in the events linked list

Event number

Event name

Event type

Event purpose

Event hour and minute

Event day

Event month

Event maximum size

Event cost

Event building

Event room

Event length

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 event info for the current event. [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 event number 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 event 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.

 

End program:

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

 

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

 

When writing the program, include substantial debugging code in the program and surround each section of debugging code with conditional compilation statements (#ifdef). At the top of your program a #define statement to control the debugging statements. When you are compiling and scripting your program you will compile it once with debugging turned on and then once with debugging turned off for the given test data doing the same tests for each script file execution.  Correct implementation and use of conditional compilation will be worth a maximum of 3% extra credit.

 

Implementation requirements:

 

WRITE A DESIGN DOCUMENT FIRST. The design should 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 all labs. See the website for the DESIGN DOCUMENT due date.

 

The program should use the following data structures:

 

An linked list of structs which should be of the struct data type you declared

Bit fields for month and day in the struct

An enumerated type for event purpose

A union for the details of the purpose

Global CONSTANTS for specific values like array indices 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 - function calls should pass in actual parameter values and return values as appropriate

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

Search and sort algorithms as described

Recursion for the predicted receipts

 

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

 

The program should be implemented as a set of functions with a main routine and at least one function for the menu of operations, two for getting input, one for printing, one for each search function, one for each sort function, and one for each calculating function. You may use many more functions than this but you must use at least this many.

 

The overall structure of the program should perform the following actions:

 

Declare and initialize the variables

Print a welcome screen for the user that introduces the system

Get the needed input values from the keyboard

Print the appropriate outputs

Let the user enter additional values until the user indicates that they are finished.

 

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.

 

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.

 

This program must be run with two different sets of test data for the input data. You must create one data set in addition to the one that I will give you and run your program with both of them. You may run it 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 set that you create must meet the guidelines given in the problem definition. It is recommended that you try to fill in your data with real information. In cases where you cannot find real data you may create the missing data.

 

NOTE ABOUT ERRORS:

 

Programs turned in for credit must compile and run without any compilation errors or runtime errors.

 

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 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.

 

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: (57%)

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

Comments (line comments and block comments) (3 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.) (3 points)

 

Correct declaration of struct type with new and changed elements (4 pts)

Correct manipulation of the struct linked list (11 points)

Correct use of required control structures (3 points)

Correct function structure as required (3 points)

 

Unlimited input implemented, no count given by user  (2 pts)

Correct recursive prediction implemented (4 pts)

Functions for goal search, goal target setting, predictions, and add and delete elements implemented (12 pts)

Remaining functions implemented correctly(4 points)

 

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

 

Output: (43%)

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

File input performs correctly (3 pts)

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

 

Recursive tasks (receipt prediction) perform correctly (4 pts)

Other search (find) tasks perform correctly (4 points)

List tasks perform correctly (2 points)

Calculate target goal tasks and other calculate tasks perform correctly (4 points)

Predict tasks perform correctly (4 points)

Sort tasks perform correctly (4 points)

Update tasks perform correctly (2 points)

Add and delete tasks perform correctly (4 points)

 

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

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

 

OPTIONAL: Extra credit: (8%)

Correctly implement and use merge sort for the linked list to sort by cost (3 points)

Correct use of command line parameter for input file name (2 points)

Correct implementation and use of conditional compilation (3 points)

 

 

Grading Deductions:

Use of global variables will result in an overall grade of 0 (zero)

Use of the exit, break (except in a switch), or continue command will result in an overall grade of 0 (zero)

Building an UNSORTED linked lists will result in 30 (thirty) point 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.

 

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

 

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

 

 

Miscellaneous:

 

Event code list:

 

One Mike Stand = 842

Wheelchair Basketball = 110

Baseball Game = 120

Basketball Game Mens = 130

Basketballl Game Womens = 140

FLOC Movie Night = 500

Jazz Ensemble = 803

Choir Concert = 810

Solo Recital = 874

Maverick Speaker Series = 990

Engineering Speaker Series = 318

Electrical Engineering Speaker = 337

Engineers Week = 301

Global Grounds Coffee Hour = 554

Art Glass Sale = 868

Library Friends = 935

The Big Event = 4

Oozeball = 8

Bed Races = 10

 

Sample data:

 

842 M C 20.00 15 2 250 10.00 UC RosebudTheatre 90 0 95 60 One Mike Stand

990 E C 20.00 19 2 1250 10.00 TX TexasHall 75 4 A 825 Maverick Speaker Series

554 C N 16.45 30 1 35 0.00 UC PaloDuraLounge 60 0 20 12 Global Grounds Coffee Hour

318 E C 18.00 3 4 350 0.00 NH 100 75 4 B 200 Engineering Speaker Series

842 M C 20.00 16 4 250 10.00 UC RosebudTheatre 90 0 100 75 One Mike Stand

4 V N 9.00 26 4 2000 0.00 LIB LibraryMall 240 5 25 120 The Big Event

868 M N 10.00 2 4 600 0.00 SAC 108 360 3 500 320 Art Glass Sale