Extra Credit Pre-Lab Assignment , CSE 1320-001 Fall 2008

 

Due Date:          See class website for due date

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

 

Grade value;     Extra credit 3% (out of 100% for all grades) added to total of lab grades.

 

Topic objectives:    Arithmetic and relational operators

                              Control structures

                              Functions

                              Multi - dimensional arrays

                              Data types

                              Global constants

                              Structures

                              Pre-processor directives

                              Pointers for passing arrays to functions

                              Searching

                              Modular programming structure

                              Error checking

                              Programming style

 

The goal for this lab is to provide an opportunity for practice of the topics covered in Chapters 1–3 and parts of later chapters (arrays, structs, simple pointers) in Foster and Foster.  These chapters 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 those concepts by creating a program.  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. 

 

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,  or linked lists.

 

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

 

Here at UTA we have lots of opportunities for engineering students to participate in fun, competitive team activities.  You are going to write a program that will capture and analyze data about the teams and the team members.  You’ll probably be surprised at all the things that UTA Engineering students do!

 

Throughout the course of the semester, you will work on developing a the team competition data analysis program.  For this pre-lab you will be given a list of students with info about each student and the teams they participate on.  Your task will be write a program to separate the students into various lists based on characteristics about each student and then to determine certain information from each list you create.  You will have to give the program’s user a set of choices that will then guide the program in what lists are created.  You will also have to report to the user the results that the program determines and the lists that are created.

 

Your specific tasks for the team program pre-lab will be:

 

¨                  Introduce the team data analysis system to a new user.

¨                  Create two-dimensional arrays to student 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, let the user do the following tasks

i.    Get a list of team competitions that UTA participates in

ii.    Find the number of people on a given team

iii.   List the members of a team

iv.   Find the average GPA of a single team or of all students who participate on teams

v.   Sort the members of a single team by student ID number, by GPA, and by last name

vi.   Search for a particular team or team member

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 a number of simplifying assumptions for this pre-lab. Many of these simplifications will be eliminated in later labs.

 

Simplifying assumptions for the pre-lab:

a) Each student is a member of only one competitive team

b) A maximum size for any team will be given

c) A maximum number of teams will be given

d) No two teams in different competitions will have the same team name, i.e. there will not be a Steel Bridge team called “Team UTA” and an ICPC team called “Team UTA”

 

Task Descriptions:

 

¨                  Introduce the team data analysis 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.

 

¨                  Create two-dimensional arrays to student data in and then populate the arrays with data.

For the pre-lab you will create a two dimensional array of student structs that will hold all the team members of each team in the subarrays, i.e. each row is a team and the student struct in each column of that row is a team member.

 

The data to put into this 2D array will be given to you as a constant 1-dimensional array of student structs.  This array will be in a separate data file (C1320F08PLtestdata.c) that you will #include at the beginning of your program.  The specification of the array you will be given in the #include file is as follows:

 

const struct {

            char lastname[45];

            char firstmidname[30];

            long int UTAID;

            double cumGPA;

            char major[4];

            char competition[45];

            char teamname[45];

}         

teammembers[25] =

{

{“Patel”, “Joshua”, 2000457234, 3.245, “CE”, “Steel Bridge”, “Blaze”},

// …another 23 records like this

{“Smith”, “Yan Akiba”, 2000943211, 2.87, “CS”, “ICPC”, “UTA Blue”}

};

 

You will need to create a two-dimensional array that can hold up to 10 different teams with a maximum of seven team members on each team.  You will then go through the struct data in the teammembers array and sort them into the new two-dimensional array by copying each record out of the teammembers array and putting each unique team into one row of the two-dimensional array and each member of that team into the same row.  So, for example, if Joshua Patel is the first person in the teammembers array then his record would be copied into the first row of the two-dimensional array.  Then the next record in teammembers that was in the Steel Bridge competition would be copied after Joshua in that row.

 

Every value in each record in teammembers should be copied into the new two-dimensional array.  The program should verify that the student GPA is valid, i.e. between 0.0 and 4.0 in value.  Any other GPA value should be reset to 0.0 .  The program should also verify that the ID number is between 2000000000 and 2000999999.  Any other ID value should be reset to 1999999999. 

 

All of the rest of the program will only use the two-dimensional array not the teammembers array.   The two dimensional array will not be full since there are many more spots in the array than there are team members in the constant array.

 

Input verification:

When the program has put all of the teammembers into the two-dimensional array, it should print out all of the team data in the two-dimensional array at each [indexteam][indexmember] 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 two-dimensional array.

 

¨                  Create and display a screen menu of 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-    List the team competitions that UTA participates in

ii-   List the members of a team

iii-  Count the number of people on a given team

iv-  Calculate the average GPA of a single team

v-   Sort the members of a single team by GPA and sort them by last name

vi-  Search for a particular team member by ID number or last name

vii-  Update the team member data

viii- End the program

 

The team list function should print a list of all the competitions that are named in the two-dimensional array giving each competition only once.  It is suggested that you number this list as you print it so that you can then used this list of competitions to search with in other functions.  The member list function should print a list of all the students that are named in the two-dimensional array for a given team chosen by the user.

 

The count function should just count the number of members that are in the array for a given team chosen by the user.  The GPA function should call the count function to help perform its function for a given team chosen by the user.

 

The two sort functions sort the subarray for a single team chosen by the user.  The user can also choose whether to sort by GPA or by last name.  Any sorting algorithm may be used.  Since these are small arrays, the bubble sort would be a reasonable choice.

 

The search option should call search functions that perform linear search on the appropriate subarrays of data. If you have one or more searches that use the same type of data, you may pass in the value to look for and the array to search and use the same search function for both. When the search is complete your program should print the search result(s) and then show the user the menu again.  In case of ties, print all results.

 

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 team member’s last name and search for that student.  Once the student is determined, save the two [indexteam][indexmember] values and give the user a menu of the following options:

 

o                   Change lastname at [indexteam][indexmember]

o                   Change firstmidname at [indexteam][indexmember]

o                   Change UTAID at [indexteam][indexmember]

o                   Change cumGPA at [indexteam][indexmember]

o                   Change major at [indexteam][indexmember]

o                   Change competition at [indexteam][indexmember]

o                   Change teamname at [indexteam][indexmember]

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 student info for the team member at [indexteam][indexmember].  

 

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

 

Implementation requirements:

The program should use the following data structures:

Struct with integer, character, and floating point elements for recording team member data

Two-dimensional array of the structs above

Pointers in function declarations to pass arrays

Global constants given as input data

 

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, or nested ifs to error check

A switch statement for implementing menus

 

The program should NOT use:

global variables

exit

goto

break

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 menu operations, one for a sort function, and one for calculating average GPA.  You may use more functions than this but you must use at least this many.  It is suggested that you also have a function for printing the team member data and a function for counting the team members on a given team but these are not required.

 

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 value 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 output must be 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.  

 

Grading scale:

Code:   (61%)

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

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

Modularity (division of the problem into small tasks, each one assigned to its own function and called from main() or from another function when appropriate--do not code the entire program in main!)  (12 points)

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

Correct manipulation of the arrays and structs (9 points)

Correct use of required control structures (8 points)

Correct function structure as required (8 points)

Proper implementation of input error checking (4 points)

Output:   (39%)

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

            Search and sort tasks perform correctly (7 points)

            Print and 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 (8 points)

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

 

Deductions:

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

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

            Use of 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:

            Competitions include:

                        Steel Bridge Building Competition

                        International Computer Programming Contest

                        Society of Automotive Engineers Race Car Team

                        Google’s Imagine Cup

                        Institute of Electrical and Electronic Engineers Robotics Competition

                        Autonomous Vehicle Laboratory competitions in Air vehicles and Ground vehicles