Due Date:             See class website for due date of Lab #1 design and of Lab #1 assignment

(see instructions on website for how to turn this in)

 

Grade value;         10% (out of 100% for all grades) of total of lab grades.

 

Topic objectives:         Arithmetic and relational operators                                   Multi-Dimensional Arrays

                                             Control structures                                                                      Data types

                                             Functions                                                                                       Global constants

                                             Pre-processor directives                                                          Searching

                                             Strings                                                                                             Sorting

                                             Modular programming structure                                         Program design

                                             Error checking                                                                            Programming style

 

The goal for this lab is to provide an opportunity for practice of program development and the C programming topics covered in Chapters 1–4 and parts of later chapters (incl. Ch. 9) in Foster and Foster. Some review material will not be covered in detail in the 1320 class and it is assumed that the student is familiar with and can use all the concepts in those chapters. This assignment is designed to practice the review concepts and new ones by creating a program. The format of this assignment will be required for the rest of the semester.

 

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), continue, structs, passing by reference (except arrays), or linked lists.

• -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • -- • --

 

At the start of any new school year, you and other students have the opportunity to get involved in campus activities. However, UTA has lots of activities that other students may not know about. Your goal for this program will be to develop a computer system that helps students learn about activities and groups on campus that they might want to get involved in. We’ll call this system the “Campus Activities System” or CAS for short.

 

Throughout the course of this semester you will work on your CAS. 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 creating components of the CAS. You will implement a program that can hold data about student activities and groups such as group name, purpose, meeting time, and so on. You will write functions that can retrieve data that matches certain criteria, that can modify the data, that can output the data, and other tasks.

 

The tasks for this pre-lab assignment will be:

 

¨                     Introduce the Campus Activities System to a new user.

¨                     Create two-dimensional arrays to store each type of the CAS data in and then populate the arrays with data.

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

1) Using the data in the arrays,

         A)   Search for activity and group choices and data by

         i.      Group number

         ii.     Group name

         iii.    Meeting day

         iv.    Purpose

B)    Count how many groups/activities have a specific purpose

C)    List all the groups/activities that meet a certain criteria

         i.      Member type

         ii.     Size

D)   Calculate

         i.      Cost to join all groups/activities

         ii.     Average cost to join any activity of a particular purpose (e.g. average cost to join any social group)

E)    Sort data in the arrays based on

         i.      Group number

         ii.     Group name

         iii.    Meeting time

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

3) End the program

 

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

 

Simplifying assumptions for the lab #1:

a) Various constants will be given for use in lab #1.

b) Group names are only one word with underscores in place of blanks. E.g. Habitat_for_Humanity

c) Group names have a max length of 25 characters for this lab.

d) All groups/activities will have a unique number. No strings will be needed for input in this pre-lab. (Later all groups and activities will be uniquely named, i.e. there will not be a “Volunteer” activity and a “Volunteer” group, they would be “Volunteer with Habitat for Humanity” and “UTA Volunteers” for example.)

 

Task Descriptions:

 

¨                     Introduce the Campus Activity System 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. (You do NOT have to clear the screen after the menu. Just let it scroll off the screen as more data is printed.)

 

¨                     Create two-dimensional arrays to store each type of the group or activity data in and then populate the arrays with data.

For lab #1, the following data will be used:

 

1.     Number representing the group or activity

 

2.     Name of group or activity

 

3.     Meeting time consisting of

         a. time of day given as hour and minute and then an ‘a’ for a.m. or a ‘p’ for p.m.

         b. day of the week given as one letter (MTWRFSN)

         c. week of the month given as ‘1’ for first week, ‘2’ for second week, ‘3’ for third, ‘4’ for fourth

 

4.     Meeting location consisting of

         a. UTA building abbreviation (no more than 4 chars in length, all one word) Ex. NH, MAC, UC…

         b. a room number in the building

 

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

         F – fun and social organization/activity just to meet like minded people

         V – volunteer organization/activity that does service activities of any type

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

         S – sports; opportunities to play or support teams

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

         M – fine arts; music, dance, art, theatre and other types of arts activities

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

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

         O – other

 

6.     Member type. Specifies what types of students are eligible to be members. If more than one of these categories applies, then for the pre-lab select the category that includes the largest number of potential members. Member types are;

         A – all students

         G – graduate students only

         M – Master’s level graduate students only

         P – Doctoral level graduate students only

         U – undergraduate students only

         4 – seniors only

         3 – juniors only

         2 – sophomores only

         1 – freshmen only

         E – engineering majors only

         B – business majors only

         L – liberal arts majors only

         S – science majors only

         R – architecture students only

         N – nursing students only

         S – social work students only

 

7.     Size. Gives number of group members or activity participants

 

8.     Cost. Gives cost to participate in the group or activity for one year

 

Forlab #1, the data above will be stored in a set of two-dimensional arrays. Each array will have 20 elements in it for a maximum of twenty groups/activities being described. (Use constants for these numbers.) The arrays are described below:

 

Integer multi-dimensional array containing:

o         Column [0] Group/activity number - the numeric code associated with a specific group or activity. For this lab we aren’t using strings so we will simply have a fixed set of groups/activities that are coded by number (ex. The Big Event = 004, SWE = 132, Student Senate = 488, etc.) and that list would be displayed in the output as described below. For all the other pieces of data, the row index [n] for some group/activity code will refer to the same activity/group for all other info as well. (See the group/activity code list at the end of this assignment and you can add to it if desired.) [Consider declaring a constant like const int GRPNUM = 0; to use as column index value]

o         Column [1] Meeting week - the week info for the meeting of the associated group/activity. The meeting week in row [n] corresponds to group/activity code [n]. Make sure that the meeting week that is entered is valid, e.g. how many weeks could there be in a month?

o         Column [2] Group/activity size - the number of people involved in the associated group/activity.

 

Character multi-dimensional array containing:

o         Column [0] Meeting half day - the a.m. or p.m. info for the meeting time of the associated group/activity. The meeting half day in row [n] corresponds to group/activity code [n]. Make sure that the character that is entered is valid. [Consider declaring a constant like const int MTGAMPM = 0; to use as column index value]

o         Column [1] Meeting day - the day of the week info for the meeting time of the associated group/activity. Make sure that the character that is entered is valid, i.e. that it is one of the allowed characters.

o         Column [2] Group/activity purpose - the code of the purpose of the associated group/activity. Make sure that the character that is entered is valid, i.e. that it is one of the allowed characters.

o         Column [3] Group/activity member type - the code of the types of students allowed to be members of the associated group/activity. Make sure that the character that is entered is valid, i.e. that it is one of the allowed characters.

o         Columns [4 through 7] Meeting building - the 4-letter building designation for the meeting location of the associated group/activity.

o         Columns [8 through 12] Meeting room - the 5-character room designation for the meeting location of the associated group/activity. Ex. 314A

o         Columns [13 through 39] Group name - the string giving the name of the associated group/activity.

 

Floating point multi-dimensional array containing:

o         Column [0] Meeting time - the hour and minute info for the meeting time of the associated group/activity. The time is represented as HH.MM as a floating point number. The meeting time on row [n] corresponds to group/activity code [n]. Make sure that the meeting hour and minute that are entered are valid.

o         Column [1] Group/activity cost - the amount in dollars and cents that it costs to participate in the associated group/activity. Make sure this amount is not negative but it can be free to participate.

 

 

For lab #1, you must implement at least two of the following three methods of input. The first method will prompt the user for each piece of data about an activity/group individually, the second method will allow the user to input all needed pieces of data about one activity/group on one line, and the third method is to read lines of activity/group data from a data file. The three forms of the input and the input data file are described below. (Just FYI, it is expected that most people will do the first two, but if you already know how to use files in C, than you are welcome to do that. We will talk about files later in the semester.)

 

For lab #1 the user must enter at least 12 activity/groups and no more than 20 activity/groups. Since the user has a choice, then the first piece of data that the program needs from the user is a count of how many activity/groups they are entering. The program should check to make sure this count is between 12 and 20. [Note for development: start with a smaller number of activity/groups then increase to 12 when program is working well ] If the user’s number exceeds 20, the program should inform the user that 20 is the maximum number of inputs allowed and have them reenter the count. Then your program must loop for count number of times (index= 0, 1, …count-1) to read and store input in one of the three following ways: Individual data method, line of data input method, or file of lines input method.

 

Individual data method (These can be done in any order)

a.     Ask the user for the activity/group 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 integer array at [rowindex][GRPNUM]

b.     For the group size do the same things using the code descriptions where appropriate (don’t forget to supply a list of codes for them) and making sure to check that the input values are meaningful. Store them in the appropriate array at [rowindex][GRPSIZE]. [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, as long as it is a positive number, there isn’t anything else to check against for this lab.]

c.     Ask the user for the week of the month that the activity/group meets. Make sure it is a valid number and then store it in the integer array at [rowindex][MTGWEEK].

d.     Ask the user for the meeting time in the format HH.MM. Make sure the hour values and the minute values are valid. Store the time value in the floating point array at [rowindex][MTGTIME].

d.     For the meeting half-day ask the user for the value and make sure it is valid. Store it in the character array at [rowindex][MTGAMPM].

e.     For the remaining data values that are letter codes (Meeting day, Purpose, Activity/group member 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 appropriate array at [rowindex] and the appropriate column index like [GRPPURPOSE].

f.      For the strings, create constants to represent the beginning of the char array storage for each string (ex. const int BLDG = 4, const int ROOM = 8, const int NAME = 13). Read in each string into a temporary array, check to make sure the string length is valid, then if it is, copy the string into the character array starting at the appropriate location. If the string is too long, copy only part of the string into the character array.

g.     Ask the user for the cost of participating in that activity/group. Make sure it is a valid value and then store it in the floating point array at [rowindex][GRPCOST].

 

Line of data input method

Your program may ask the user to enter all the information for one activity/group on the same line. This data would be an integer for activity/group code, an int for size, an int for week of the month, float or double for meeting hour and meeting minute, chars for half day and day of week, chars for purpose and member type, strings for building abbreviation, room number and group name, and a float or double for cost. You must tell the user exactly how to enter the line of data. The data for a single activity/group will be entered by the user as values on one line as follows {there must be one space only between the values}:

 

> 132 43 1 12.0 p M P E NH 110 SWE 15.00

 

which represents the Society of Women Engineers (Group 132) with 43 members meeting in the 1st week of the month at 12:00pm (which is noon) on Monday. It is a professional organization for engineering students, it meets in Nedderman Hall room 110, the group name is SWE, and the yearly cost is $15.00.

 

Your program will read the first number and store it in the integer array at some location [rowindex][GRPNUM], then read and store the size, then the week of the month ints into the corresponding location [rowindex][GRPSIZE] or [rowindex][MTGWEEK] in the integer array, then read and store the hours and minutes HH.MM into location [rowindex][MTGTIME] in the floating point array, and so on. Your program should read multiple input values within a single input command but multiple input (scanf) commands can be used. Your program should read in as many lines of input for activity/groups as were originally specified by the count up to the maximum of twenty lines of input (activity/groups).

 

File of lines input method

You may create a file that contains between 12 and 20 lines of activity/group data and you may read the data from this file. To do this will requires creating file variables, opening the file and linking it to the file variable, and then reading the data from the file variable in the same way that a line of data would be read from the screen. This must be done using C file commands. The first line of data in the file should have only one integer on it which is the count of the number of lines of activity/group data which follow in the file. (File input may or may not be covered in class prior to this lab’s due date so you might have to learn this on your own if you wish to use it in the lab #1. It will be covered and required for later labs in the class.)

 

Input verification:

When the user has entered count number of activity/groups, print out all the input activity/group data in an easily readable form, ex. use a table with headings, or columns with headings or rows with labels. It is required 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 an activity/group given the activity/group code as input. The function could have a switch or a bunch of if statements in it.

 

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

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

 

i.          Search for a type of activity/group by number

ii.        Search for a type of activity/group by name

iii.      Search for a type of activity/group by meeting day

iv.      Search for a type of activity/group by purpose

v.        Count how many groups/activities have a specific purpose

vi.      List all the activity/groups that accept a certain member type

vii.    List all the activity/groups that are equal or greater than a certain size

viii.  Calculate cost to join all groups/activities

ix.      Calculate average cost to join a groups/activities of a particular purpose

x.        Sort data by group number

xi.      Sort data by group name

xii.    Sort data by meeting time

xiii.  List all the activity/groups

xiv.  Update the data in the arrays

xv.    End the program

 

 

 

The search functions should let the user choose the group code number or group name or meeting day or purpose code and then look through the list to find the first activity/group that matches that type, then print a sentence stating that matching code/day was or was not found and if found, it should also print the code and the name of the group/activity.

 

The count function should let the user choose a purpose code and then go through the data and count (#) how many groups/activities have that purpose. The output should be a sentence stating that the number of groups/activities with that purpose is #.

 

The member type list function should let the user choose a member type (using the codes your program gives them) and then should print all the groups/activities that allow that member type. This one is a little tricky in that some groups are subgroups of others, e.g. if the user chooses type 3 for juniors then any group that accepts U undergrads also accepts juniors and any group that accepts A all students also accepts juniors. Make sure to print a message at the top of the list explaining what is being printed.

 

The size list functions should let the user choose a size value and then should print all the groups/activities that are of that size or larger. Make sure to print a message at the top of the list explaining what is being printed.

 

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

 

The calculate average cost function asks the user to choose a purpose (from the list of purpose codes), then goes through the list sums all the costs of groups with that purpose and then divides by the number of those groups to get the average cost of that type of group.

 

The sort data by group number will do a bubble sort on the list and order the list from smallest group number to largest group number. Remember to sort ALL the data associated with that group number. Print all the sorted data.

 

The sort data by group name will do a selection sort on the list and order the list alphabetically by name. Remember to sort ALL the data associated with that group name. Print all the sorted data.

 

The sort data by meeting time will do a bubble sort on the list and order the list from earliest time in the morning to latest time at night ignoring what day the groups meet. Remember to sort ALL the data associated with that meeting time. Print all the sorted data.

 

The list activity/groups function is the same as the print function described for input verification.

 

The update option should take the user to a second screen to allow them to update information in the arrays. This screen should ask for a activity/group code from the user and search for that activity/group. Once the correct activity/group is determined save its [rowindex] and give the user a menu of the following options:

 

o                      Change Group name at [rowindex]

o                      Change Meeting time, half day, day, or week at [rowindex]

o                      Change Meeting building, or room at [rowindex]

o                      Change Purpose at [rowindex]

o                      Change Member type at [rowindex]

o                      Change Size at [rowindex]

o                      Change Cost at [rowindex]

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

 

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 ON PAPER FIRST. The design should include a list of the functions you expect to write with brief (one line) descriptions and a diagram showing what function calls what other functions. This diagram should start with the main function at the top and all others below it. 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. This design documentation is required to be turned in for Lab 1. The lab design is due ONE WEEK before the lab is due.

 

The program should use the following data structures:

Two dimensional integer, character, and floating point arrays

Global CONSTANTS for specific index and/or maximum values given in this assignment. Constants can be done with

#define or with the const declaration. Examples:

 

#define GROUPMAX 10

const int GRPNUM = 0;

 

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:

structs

global variables

exit

break (except in switch)

continue

pointers

                  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 menu operations, two for getting input, one for printing, one for a search function, two for sorting, and two for calculating. You may use many more functions than this but you must use at least this many.

 

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

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.

 

This program must be run with two different sets of test data for the team member constant 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.

 

The program must be run and the output recorded in a script file from OMEGA using the gcc compiler. 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.

 

Programs turned in for credit must compile and run without any compilation errors or runtime errors. Programs may be partially complete but all completed functions must run without any errors. A program has a runtime error if it 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.

 

Grading scale:

Code:     (54%)

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

Comments (line comments and block comments)      (6 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!) (4 points)

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

Correct manipulation of the 2-dimensional arrays (9 points)

Correct implementation of bubble sort for ints and floats and selection sort for strings (7 points)

Correct use of required control structures (5 points)

Correct function structure as required (5 points)

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

Output:  (46%)

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

                  Search (find) tasks perform correctly (6 points)

                  Sort tasks perform correctly (6 points)

                  List tasks perform correctly (4 points)

                  Calculate tasks perform correctly (4 points)

                  Update tasks perform correctly (6 points)

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

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

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

Grading Deductions:

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

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

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

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

                  Use of structs or linked lists will result in 50 (fifty) point deduction per use

                  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

                  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:

 

Activity/group code list:

The Big Event = 004

Oozeball = 008

Bed Races = 010

JCEO/ESC = 130

SWE = 132

SHPE = 133

NSBE = 134

TSPE = 135

ACM = 140

GDC = 141

IEEE = 150

IIE = 160

BMESS = 170

BMES = 171

SACNAS = 221

Concert choir = 512

Marching band = 525

Student Senate = 488

FLOC = 490

UTA Volunteers = 491

BSA = 610

FSI = 630

 

Sample data:

008 120 3 6.0 p F S A MAC VB1 Oozeball 15.00

132 43 1 12.0 p M P E NH 110 SWE 15.00

490 88 3 12.30 p W V A UC 212A FLOC 0.0