Lab #3 Assignment

CSE 1320-001

Spring 2011

Due Date:         See class website for due date

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

Grade value:    10% 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 Chapters 1–7 and parts of later chapters 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: 

            Algorithms

            Structs

            One-dimensional Array

            Strings

            Control structures

            Functions

            Arithmetic and relational operators

Input and output,

Passing parameters

            Data types

            Global constants

            Pre-processor directives

            Searching

            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 for making travel plans.  You are going to put together a small database of information to help make travel arrangements.  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), continue, passing by reference (except arrays), or linked lists.

 

Assumptions for the lab #3:

 

1) A maximum of 10 legs per trip are allowed.  Use constants to define the max value.

2) Strings will have a maximum length but will contain blanks and punctuation.

3) The maximum number of trips for Lab #3 is 12.  Use constants to define the max value.

 

 

Problem:  The data in your database will be travel destinations, information about getting to these locations, and other data needed to plan or manage a trip.  As part of this assignment you will have to find real data about these destinations to use as test data for your program.

 

When the user runs your program, they must first enter data.  The data they entering will be the travel information that you have researched to use as your test data.  After getting all the input data for the destinations from the user (and storing it in arrays), you will allow the user to do the following:

 

1)   Using the data in the arrays,

      A)  Search for destination by

            i.    Type of travel

            ii.   Continent or area

            iii. Date of trip

            iv.  Destination name

      B)  Calculate

            i.    Cost for purchase of tickets for travel

            ii.   Length of trip without the travel time

      C)  List all the destinations that meet certain criteria

            i.    Less than given cost

            ii.   Less than a given travel time

            iii. In the same continental area

            iv.  In the same country

      D)  Sort the data by

            i.    Destination code

            ii.   Travel date

            iii.  Name

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

3) End the program

 

 

Data Description:  For lab #3, you will be storing the input data in a single array of structs for trips which will contain a single dimensional array of structs for legs.

 

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

 

1) Destination code - a five digit integer where the digits represent a city or location using the guidelines given at the end of the assignment.  You will have to validate the 10000s place and 1000s place of any code entered by the user.  For the first destination, the destination code would be read in and error checked.  If the value is valid, i.e. it passes error checking, then it is stored in the destination code member of the struct for this trip.

 

2) Destination name - a string less than 40 characters long that gives the destination name.  In lab #3 we are using strings for the name which may have multiple word, i.e. San Antonio is a valid name for this lab.

 

3) Area letter code - a letter representing the kind of destination.  Choices are:

S Small city - population under 50,000

M Medium city - population between 50,000 and 500,000

L Large city - pop. over 500,000

N Natural formation like a mountain, a lake, a cave, a geyser, a fjord, a canyon, etc.

P Designated park or reserve such as a wildlife refuge, a national park, a bioreserve, or a protected marine area

K Man made landmark like the Great Wall of China, the Taj Mahal, or Stonehenge

R State or province or region of a country

C Whole country

U Multiple countries like traveling through Europe

W Ocean voyage

O Any other type of destination - such as visiting the sites of the seven wonders of the world

 

4) Travel start date as day, month, and year – three separate numbers

 

5) Travel end date as day, month, and year – three separate numbers

 

6) Number of legs of travel to reach destination (max of ten legs)

 

6a) Travel type for a leg (one code letter per leg) Codes are:

A Airplane

R Train and rail travel

B Bus

C Car

F Ferry

S Cruise ship

M Motorcycle

Y Bicycle

T Boat other than a ferry or cruise ship

D Dirigible

O Other

 

6b) Travel length for a leg (one length in hours and minutes per leg including layover time) - save as a floating point value HH:MM

 

6c) Cost per leg (one amount per leg) in dollars and cents - save as a floating point value

 

7) Total time to reach destination (from first departure to final arrival; i.e. the sum of all the travel lengths) in days, hours, and minutes

 

8) Length of trip from start to end minus travel time in days

 

9) Number of adults traveling (age 18 or older)

 

10) Number of children ages 2 through 17

 

11) Number of infants less than age 2

 

12) Destination country – a string with the name of the country of destination

 

The format for each piece of data is listed below. 

 

You will create a struct data type to hold a trip.  The struct type will hold all the data items for one trip including an array for the data in the legs.  The leg data will be another struct type an you will have an array of size 10 of the struct leg type as one member of the struct trip type.  Declare the struct types globally and then declare the arrays inside main.  You will have an array of 12 elements of type struct trip to store up to 12 trips.  The members of the struct trip type are:

 

As an example, let's say the user is going to enter data for two trips.  The first trip will be to Yellowstone_National_Park (code 13500) and the second trip will be traveling around Germany (45999).  For each trip you will be asking the user for all the pieces of data listed above and storing this data into the array of structs.  The different trips, in this case the first trip and second trip, will be stored on different rows.  Each member of the struct will indicate a different piece of data about the trip. 

 

Make sure to declare all your constants before you try to use.

 

Destination code - an integer where the digits represent a city or location using the guidelines given at the end of the assignment.  You will have to validate the 10000s place and 1000s place of any code entered by the user.  For the first destination, the destination code would be read in and error checked.  If the value is valid, i.e. it passes error checking, then it is stored in the struct trip array in the destcode member for this trip, e.g. travel[tripnum].destcode .

 

Destination name - a string less than 40 characters long that gives the destination name. The string will be read in with the getline command into a temporary string.  The length of the string should be checked using the strlen command.  If the string is less that 40 chars in length then it should be copied to travel[tripnum].destnam in the array.

 

Area letter code - a single character representing the kind of destination.  It must match one of the valid series/event codes.  If it is valid, it should be stored in the array at travel[tripnum].area .

 

Travel start day is an integer value.  It should be error checked and then a valid day value stored at travel[tripnum].trsday .

Travel start month is an integer value.  It should be error checked and then a valid month value stored in the travel array at index tripnum in the member trsmo.

Travel 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 at travel[tripnum].trsyr

 

Travel end day is an integer value.  It should be error checked and then a valid day value stored at travelint[tripnum].treday .

Travel end month is an integer value.  It should be error checked and then a valid month value stored in the ravel array at index tripnum in the member tremo.

Travel 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 at travel[tripnum].treyr

 

Number of legs is an integer value.  It should be error checked and then a valid day value stored at travel[tripnum].numlegs

 

There are three pieces data per leg and they should be stored in a struct leg array, e.g. legs

 

Travel type is one letter per leg per trip.  It should be error checked and then a valid type code stored at travel[tripnum].legs[legnum].travtype

 

Travel length for a leg is a floating point value in the form HH.MM where HH is the number of hours less than 24 and MM is the minute value.  It should be error checked and then a valid length stored at  travel[tripnum].legs[legnum].len

 

Cost per leg is a floating point value.  It must represent valid dollars and cents.  The cost of a leg can be free.  A valid ticket price should be stored in the float array at  travel[tripnum].legs[legnum].cost

 

Total travel days is an integer value.  It should be calculated from the sum of the lengths of travel time for all legs and then a valid number of days stored at travel[tripnum].totday. This is only calculating how long it takes to get from the starting point to the destination (one way), not the length of the entire trip.  This value should be calculated automatically by your program after the data for all the legs is entered.

Total travel hours is an integer value.  Once the total number of days is determined, then the remaining hours should be calculated and a valid number of hours stored at travel[tripnum].tothr. This value should be calculated automatically by your program after the data for all the legs is entered.

Total travel minutes is an integer value.  After the total number of days and hours is determined, then the remaining minutes should be calculated and a valid number of minutes stored at travel[tripnum].totmin. This value should be calculated automatically by your program after the data for all the legs is entered.

 

Trip length is an integer value.  It will be calculated, when requested by the user, from the start day to the end day of the trip minus the number of days of travel.  This is the length of the entire trip and should be stored in travel[tripnum].triplen

 

Adult is an integer value.  It should be error checked and then a valid number of adults stored at travel[tripnum].adult.

Child is an integer value.  It should be error checked and then a valid number stored at travel[tripnum].child .

Infant is an integer value.  It should be error checked and then a valid number stored at travel[tripnum].infant.

 

Destination country - a string less than 40 characters long that gives the destination country. The string will be read in with the getline command into a temporary string.  The length of the string should be checked using the strlen command.  If the string is less that 40 chars in length then it should be copied to travel[tripnum].country in the array.

 

 

Input Implementation:  For Lab #3 the user must enter at least 4 destinations and no more than 12.  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 trips/destinations they are entering.  The program should check to make sure this count is between the min and max. [Note for development: start with a smaller number of destinations then increase to min when program is working well.] If the user’s number exceeds the max, the program should inform the user that MAXTRIPS is the maximum number of inputs allowed and have them reenter the count. Then your program must loop for count number of times (tripnum= 0, 1, …count-1) to read and store input.

 

 

For Lab #3, you must implement the following two methods of input.  The first method will prompt the user for each piece of data individually and the second method will allow the user to input all needed pieces of data about one destination on one line.  The two forms of the input are described below. After getting the count of destinations from the user, the program must ask the user how they want to input the data.  Your program must give them both choices of methods:  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.

 

 

Individual data method:

a.         Ask the user for the destination 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 array in the correct struct member at the correct row [tripnum]   As an example of an explanation, you might tell the user "Please enter a destination code.  Codes should be five digits with the first digit representing the continent, the second digit indicating what kind of destination it is and the last three digits just being a unique code…" and then you can list the continents and kinds of destinations for them to use. See the Miscellaneous section at the bottom for the destination code info.

b.         Ask the user for the area letter code and give them the choices. Check to make sure it is a valid type.  Store this valid character in the struct array travel[tripnum].area .

c.         Ask the user for the month, day, and year for the start of the travel.   Make sure it is a valid date, i.e. it is a real date and it is in the future, and then store it in the struct array at travel[tripnum].trsmo, travel[tripnum].trsday,and travel[tripnum].trsyr.

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

e.         Ask the user how many legs of travel there are from the user's starting location to the desired destination, i.e. two plane legs and a ferry ride would be 3 legs.  Store the number of legs in the array at the correct location, travel[tripnum].numleg

f.          For each leg,

1.         Ask the user for the travel type code letter and give them the choices.  Check that they entered a valid code letter and then store it at travel[tripnum].leg[legnum].travtype

2.         Ask the user the length of travel time in hours and minutes for that leg entered as a floating point value representing HH.MM .  Check that the value is positive and that MM is less than 60.  (HH can be any value because it might represent multiple days like on a ship.)  Store the time in the floating point array at travel[tripnum].leg[legnum].len.

3.         Ask the user for the cost of that leg of travel entered as a floating point value representing US dollars and cents (ex. 450.99).  Check that the cost is valid and store in the floating point array attravel[tripnum].leg[legnum].cost.

g.         Ask the user for the number of adults, ages 18 and older, who will be traveling on this trip.  Check for validity and save this value in the array travel[tripnum].adult.

h.         Ask the user for the number of children, ages 2 through 17, who will be traveling on this trip.  Check for validity and save this value in the  array .

i.          Ask the user for the number of infants, under age 2, who will be traveling on this trip.  Check for validity and save this value in the array.

j.          Ask the user for the string name of the destination followed by a comma and one blank and then the name of the destination country.   Read all of it into a temporary string.  Break the temp string into two tokens at the comma and check the length of the two shorter strings.  If each is OK, store them into the struct array at row [tripnum].

 

 

Line of data input method:

Your program may ask the user to enter all the information for one trip on the same line.  This data would be an integer for destination code, ints for day, month, and year of start and end along with counts of legs and travelers, chars for area code and travel code, floats for leg cost and length, and a string for the name of the destination and its country.  You must tell the user exactly how to enter the line of data. 

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

 

> 11006 L 7 29 2011 8 7 2011 1 C 4.10 57.34 2 0 0 San Antonio, United States

 

which represents a trip to San Antonio (code 11006, name San Antonio in country United States) from July 29. 2011 to August 7, 2011 with one leg by car for 4 hours and 10 minutes with a cost of $57.34.  Two adults are traveling with no children or infants.

 

And a second example:  [NOTE: this example is longer because the trip has two legs instead of one]

 

> 13953 P 12 26 2011 1 5 2012 2 A 3.30 249.00 A 2.0 148.00 3 0 2 Sierra Del Rosario, Cuba

 

which represents a trip to Cuba's Sierra Del Rosario  (code 13953, name Sierra Del Rosario in Cuba) from Dec. 26. 2011 to Jan. 5, 2012 with two legs of the trip.  The first leg is by airplane for 3 hours and 30 minutes with a cost of $249.00.  The second leg is also by plane with a time of 2 hours and a cost of $148.  Three adults and two infants are traveling.

 

Your program will read the first number and store it in the struct array at the correct location, then read and store the character into the corresponding location in the array, then read and store the third number (month) into the array, and so on.  Your program should read the numbers, chars, and the string with a minimum number of input commands.  Your program should read in as many lines of input for destinations as were originally specified by the count up to the maximum of twelve lines of input (trips). 

 

 

Input verification:

When the user has entered count number of trips, print out all the input trip 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 array.  It is also suggested that a small function be written which will print the name of a destination given the destination 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 destination by type of travel

B)  Search for destination by date of trip

C)  Search for destination by area or continent
D)  Search for destination by destination name

 

E)  Calculate cost for purchase of tickets for travel

F)   Calculate length of the trip without travel time

 

G)  Find all the destinations in the same continent

H)  Find all the trips that are shorter than a given travel time (from start to destination)

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

J)   Find all the destinations in the same country

 

K)  Sort the data by destination code

L)  Sort the data by trip start date

M) Sort the data by destination name

 

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

O) End the program

 

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

 

The calculate-cost function will ask the user for a particular destination code from those in the database (print the table of trips) and will then calculate and print the total cost of the tickets for all the travelers listed for that trip.  You may save the trip costs in a floating point array of costs if desired.  The cost of any trip is calculated as follows:

The sum of the cost of all the legs is the half-trip cost. 

The total trip cost for one adult is two times the half-trip cost.

The total trip cost for one child is equal to the half-trip cost.

The total cost for one infant is half of the half-trip cost.

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

 

The calculate-length-of-trip function will find the total number of days of the trip excluding the travel time.  The calculation is to take the start day of the trip and count the number of days until the end of the trip (remember to include the start and end day in the count) then subtract two times the number of days of travel time.  For purposes of this calculation, you can ignore the total hours and minutes of travel time. 

 

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

 

The find-all-shorter-trips function should ask the user for a number of days, hours and minutes and then go through every destination and print the complete information for all destinations that have a total travel time shorter than the given travel time.  This is the time to go from the start to the destination, not the total length of the trip.

 

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

 

The find-all-in-country function should ask the user to enter the desired country then go through every destination and print the complete information for all destinations that are in that country.  You will have to use the country name string to determine this.

 

Sort-by-destination-code should use bubble sort to order the arrays based on the destination codes from smallest to largest.

 

Sort-by-date should use bubble sort to arrange the arrays in order based on the date of the start of the trip 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-destination-name should use selection sort (from the book) to order the arrays based on the destination names from alphabetically.

 

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 destinations in the database for them to choose from, ask for a destination code from the user, and search for that destination.  Once the correct destination is determined save its [index] and give the user a menu of the following options:  [NOTE: for Lab #3, you will not have to make changes to the data for the legs of the trip. You will do so in later labs.]

 

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

      o   Change the number of travelers at [index]

      o   Change the area letter code at [index]

      o   Change the name at [index]

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

 

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

 

 

Implementation Requirements:

 

WRITE A DESIGN DOCUMENT FIRST.  The design must include

 

      a) all the functions you expect to write,

 

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

 

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

 

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

 

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

 

 

The program should use the following data structures:

            Single-dimensional struct arrays

            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

            pointers

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

 

Programming practices:

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

 

Example 1:

/* Find A by multiplying L times W */

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

 

Example 2:

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

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

 

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

 

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

 

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

 

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

 

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

            Declare and initialize the variables

            Print a welcome screen for the user that introduces the system

            Get the needed input values from the keyboard or file

            Print the appropriate outputs

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

 

Output requirements:

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

 

You must come up with information to use as test data for at least 12 destinations and trips. You may only have one trip that is a single leg - all other trips must have multiple legs.  Please use real data for trips and costs.  Feel free to use travel websites to "plan" the trip data for this lab.  See the Miscellaneous section below for other useful info.

 

Testing:

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

 

NOTE ABOUT ERRORS:

 

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

 

Compilation errors 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

 

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

            Program style:

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

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

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

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

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

            Correct manipulation of the struct array  (8 points)

            Correct use of required control structures  (5 points)

            Correct implementation of bubble sort (2 points)

            Correct implementation of selection sort (4 points)

            Correct function structure as required (5 points)

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

Output:              (44%)

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

            Sort tasks perform correctly  (8 points)

            Search tasks perform correctly  (8 points)

            Find-all tasks perform correctly (4 points)

            Calculate tasks perform correctly (5 points)

            Update tasks perform correctly (6 points)

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

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

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

 

 

Grading Deductions:

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

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

            Use of linked lists will result in 50 (fifty) point deduction per use [-50 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]

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

                        student has obtained prior instructor approval [-100 deduction]

            Use of C language elements not yet discussed in class by the lab due date will result in potential deduction of points - discuss with instructor before using.

 

 

Miscellaneous:

 

Destination code structure:  The code will be a 5-digit number.  The leftmost digit (10,000s place) will indicate the continent as follows:

1 North America

2 South America

3 Asia

4 Europe

5 Africa

6 Australia

7 Antarctica

 

Following the continent value will be a value in the 1000s place that indicates if the destination is a city, a land form of some kind, or other types of locations.  The codes for that digit will be:

1 City (any size)

2 Natural formation like a mountain, a lake, a cave, a geyser, a fjord, a canyon, etc.

3 Designated park or reserve such as a wildlife refuge, a national park, a bioreserve, or a protected marine area

4 Man made landmark like the Great Wall of China, the Taj Mahal, or Stonehenge

5 State or province or region  (for example if traveling around Saskatchewan)

0 Any other type of destination - such as visiting the sites of the seven wonders of the world

 

Therefore, a destination code for Washington, DC, USA might be 11100 for North America, city, and then code 100 for DC.  Likewise Arlington, TX might be 11001 where Arlington is 001.  The Taj Mahal could use a 3 digit code like 123 and its destination code would be 34123. 

 

Sample data:

 

11006 L 7 29 2011 8 7 2011 1 C 4.10 57.34 2 0 0 San Antonio, United States

13953 P 12 26 2011 1 5 2012 2 A 3.30 249.00 A 2.0 148.00 3 0 2 Sierra Del Rosario, Cuba