p.MSOFOOTER {mso-bidi-font-family:"Times New Roman";} li.MSOFOOTER {mso-bidi-font-family:"Times New Roman";} div.MSOFOOTER {mso-bidi-font-family:"Times New Roman";} p.MSOTITLE {mso-bidi-font-family:"Times New Roman"; mso-bidi-font-weight:normal;} li.MSOTITLE {mso-bidi-font-family:"Times New Roman"; mso-bidi-font-weight:normal;} div.MSOTITLE {mso-bidi-font-family:"Times New Roman"; mso-bidi-font-weight:normal;} p.MSOBODYTEXTINDENT3 {mso-bidi-font-family:"Times New Roman";} li.MSOBODYTEXTINDENT3 {mso-bidi-font-family:"Times New Roman";} div.MSOBODYTEXTINDENT3 {mso-bidi-font-family:"Times New Roman";} @list L1:level1 {mso-bidi-font-family:"Times New Roman";}

Lab #1 Assignment , CSE 1320 Spring 2007

 

Due Date:       See section website for due date

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

 

Topic objectives:   Arithmetic

                              Multi - dimensional arrays

                              More control structures

                              Strings

                              Searching (linear search)

                              Sorting (bubble sort)

                              File input

 

Do you enjoy eating out? If only I could always pick a good restaurant for my favorite types of food! Since almost everyone enjoys eating out, you are considering creating a program to recommend restaurants based on a variety of factors such as type of food, number of entrée choices on the menu, average entrée cost, distance, age of the restaurant, family-friendliness, average wait time, hours of operation, and other factors. This lab assignment will contain all the info needed to do the lab but you might want to read the pre-lab if you didn’t write the program just for background.

 

To start developing your restaurant recommendation program you will start by creating the program structure and putting in some of the desired functionality. The task descriptions tell what each task entails and the implementation requirements specify certain things that must be done certain ways for this lab.

 

The overall tasks for this lab assignment will be:

 

¨              Introduce the restaurant recommendation system to a new user.

¨              Create a multi-dimensional array and a string array to store all of the restaurant data in and then populate the arrays with data through input from a file and through calculation of some values.

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

1) Using the data in the arrays, search for restaurants by

i.    Total cost estimate for dinner for x number of guests

ii.   Distance

iii.  Type of food

iv.  Number of choices

v.   Children’s and seniors’ menus availability

vi. Newness of the restaurant

vii. Hours of operation

viii. Average wait time

2) Sort the array by average entrée cost or by restaurant name

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

4) End the program

 

 

Each of these tasks is described in more detail below. You might want to imagine that your program would be used by two different people, one who inputs the data and then another one who uses the data to search and sort and update. 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 lab #1:

a) All distances will be calculated from Nedderman Hall at UTA.

b) Each restaurant serves only one kind of food using the codes given below

c) Opening and closing are always within the same day (nobody stays open past midnight in a single day)

 

Task Descriptions:

 

¨              Introduce the restaurant recommendation 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 a multi-dimensional arrays to store all of the restaurant data in and then populate the arrays with data through input from a file and through calculation of some values.

For lab #1, the single element restaurant data will be stored in one multi-dimensional array of 11 pieces of data by 10 restaurants. There will also be an array of strings to hold the restaurant name. The data elements are described below. Make sure the multi-dimensional array is of a data type that can represent all the required information. All restaurant data to be given by the user must be in a file and the program will read the pieces of data from the file. The format for a line of the data file is given later in this description. The pieces of data for each restaurant are as follows:

o               Restaurant name – an array of strings to hold a name of length <= 30 characters. For this lab you will read this data from a file and each restaurant name must have no blanks in it. For example the input file should read Kentucky_Fried_Chicken or KentuckyFriedChicken for that particular restaurant. The string at index [n] for some restaurant name in this array will refer to the same restaurant data in the multi-dimensional array.

o               Restaurant code – the integer numeric code associated with a particular restaurant. For all the other pieces of data, the index [n] for some restaurant code will refer to the same restaurant for all other info as well.

o               Type of food– the letter code for the type of food served at the restaurant. You must specify in your comments and in your information for the user what the meaningful character abbreviations are. Ex:‘H’ for hamburgers, ‘P’ for pizza, ‘I’ for Indian food, etc. as YOU define it. The type of food for restaurant [n] corresponds to restaurant code [n].

o               Number of entrée choices–the number of different entrees available at that particular restaurant [n].

o               Average entrée costs– the average cost of an entrée at restaurant [n].

o               Distance in miles– the distance in miles from UTA Nedderman Hall to restaurant [n].

o               Children’s menu available– a value indicating whether or not a children’s menu is available.

o               Senior’s menu available–a value indicating whether or not a seniors’ menu is available.

o               Age of the restaurant–the age in months of that particular restaurant [n].

o               Hours of operation–two values : an opening time and a closing time of that particular restaurant [n]. The time must be stored as a military time (a 24 hour clock instead of 12 hours AM and 12 hours PM) Ex: 10:00am would be 1000 military time while 10:15pm would be 2215 military time.

 

Given the string array and the multi-dimensional array the program must read data from an input file named “lab1inSpr07.dat” and store it into the correct array. This way you can create a file of data one time and then use the same file for input on every program run. There will also be a sample data file posted on the website which your program must run with.

 

There may be more or less than 10 restaurants in the input file. The program should read input until either it has run out of data (reached EOF) or until it has read 10 lines of restaurant data into the arrays. Each line of the file will have the following data items in the following order each separated by a single space. Note that these data items correspond exactly in order to the list of data above:

 

restname restcode foodtype numchoices avgcost dist childrens seniors age opening closing

 

So as an example, Rocco’s Pasta, coded as 072, with Italian food, 32 choices, average entrée cost of $8.50, 1.8 miles from Nedderman Hall, with a children’s menu but no seniors’ menu, a restaurant age of 8.5 years, and hours of operation from 11am to 11pm would look like the following line in the input file:

 

Roccos_Pasta 072 I 32 8.5 1.8 Y N 102 1100 2300

 

Your program must create a file variable and link it to the file “lab1inSpr07.dat” and open the file for reading. Then the program must read the data from the input file into the multi-dimensional restaurant array of size 11x10 as specified above. This means that in the string array restaurantname[n] will have the name of the nth restaurant and that if the 11x10 matrix is called something like ”restaurant” then restaurant[0][n] will be the restaurant code for the nth restaurant in the list, restaurant[1][n] will be the type of food of the nth restaurant in the list, restaurant[2][n] will be the number of entrees, etc. up to restaurant[9][n] which will be the closing time for the nth restaurant.

 

To read the data from the file, your program should read the eleven elements from each line, store the nth restaurant name into the name array and store the other 10 elements in the nth restaurant of the multi-D array. Make sure to check for the validity of

            Number of entrée items >= 0

            Average cost of entrée >= 0

            Distance in miles >= 0

            Menu for children and for seniors has valid response

            Restaurant age >= 0

            Opening hours >= 0 and <= 2359 (remember military time)

            Closing hours with same limits and “after” opening.

 

Input verification:

When the program has read in the available restaurants from the file, print out all the restaurant data in an easily readable form, ex. use a table with headings, or columns with headings or rows with labels.

 

¨              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-   Search for a restaurant

ii-   Sort the restaurant data

iii- Update restaurant data

iv-  End the program

 

The search, sort and update options should take the user to a second screen to allow them to specify which search or sort or piece of data to update.

 

i-   Search for a restaurant

All of the search options should call search functions that perform linear search on the appropriate part of the array of data. Allow the user to enter a value(s) to search for. 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 and/or multiple answers, print all results.

 

i-    Search for a restaurant by the estimated cost of a meal for x number of people

ii-   Search for a restaurant by distance – user gives a preferred range

iii-  Search for a restaurant by type of food

iv-  Search for a restaurant by number of choices available

v-   Search for a restaurant by whether it has children’s and/or seniors’ menus available

vi-  Search by restaurant age

vii- Search by hours of operation

viii-Search by average wait time

 

For the estimated meal cost search you must ask the user to enter the number of diners x and the maximum acceptable meal cost. Your program then performs the following calculation for each restaurant:                 estimated meal cost = average entrée cost * 1.5 * x

      If the estimated meal cost is less that the user’s maximum the print the restaurant and the estimated cost for the user.

For distance searches be sure to include the distance to the restaurant in the output info.

For the average wait time search get the user’s maximum wait time and then perform the following calculation for each restaurant:           

      If closing time is 9pm or earlier or if restaurant is more than 3 years old, wait time = 0;

      If closing time is after 9pm up to 11pm and the restaurant is less than 1 year old, wait time = 45min;

      If closing time is midnight and restaurant is less than 2 years old, wait time = 30 minutes;

      Else wait time is 15 minutes;

 

ii-   Sort the restaurant data

The sort options should call sort functions that perform bubble sort on BOTH entire arrays of data based either the restaurant name or the average entrée cost. Both arrays must be sorted together otherwise the names in the string array would not match the data in the multi-D array.

 

iii- Update restaurant data

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 restaurant code from the user and search for that restaurant. If multiple restaurants with that code are found, ask the user for the distance (i.e. in case two McDonald’s are in the list). Once the correct restaurant is determined save its [index] and give the user a menu of the following options:

 

o               Change Type of food array at [1][index]

o               Change Number of entrée choices at [2][index]

o               Change Average entrée costs at [3][index]

o               Change Distance in miles at [4][index]

o               Change Children’s menu available at [5][index]

o               Change Seniors’ menu available at [6][index]

o               Change Age of the restaurant at [7][index]

o               Change Hours of operation– opening time of that particular restaurant at [8][index]

o               Change Hours of operation– closing time of that particular restaurant at [9][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 restaurant info for the restaurant at [index].

 

iv-  End the program

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

 

Inputdata:

To create your input data file go online and collect data for at least 10 different restaurants in DFW. You must include at least five different types of restaurants, e.g. you cannot have 5 McDonald’s and 5 Pizza Huts in your list. Include a comment in your code or your script session telling what day you collected the data and what website(s) you used for data collection. Use maps and driving distances to get the distance values.

 

 

Implementation requirements:

The program should use the following data structures:

Multi-dimensional array for recording restaurant data

Array of strings for restaurant names

Input data file

 

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 the first number and implement the menu options

Switch if desired

 

The program should NOT use:

structs

global variables

exit

break

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 getting input from the user, one for a search function, one for a sort function, one for calculating wait time and one for calculating estimated cost. You may use 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 value from the file

Print the appropriate outputs

Let the user enter additional choices 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 three different sets of data for the restaurant data. You must create three data sets and run your program with them. You may run it three times within a single execution or you may execute the program three different times so that you have a total of three different data sets. The sample data sets 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 or OIT how to use this function.

 

Grading scale:

Code:   (58%)

Program header and function headers for all functions           (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!) (10 points)

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

Correct use of input data file (9 points)

Correct manipulation of the multi-dimensional array (9 points)

Correct manipulation of the array of strings (7 points)

Correct use of required control structures (5 points)

Correct function structure as required (6 points)

Proper implementation of input error checking (6 points)

Output:      (42%)

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

            Search (find) tasks perform correctly (5 points)

            Linear search implemented (4 points)

            Calculation of estimated cost performed correctly (5 points)

            Sort tasks perform correctly (8 points)

            Bubble sort implemented (4 points)

            List of inputs correctly printed (4 points)

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

            Output contains all the sample data and two additional data sets (4 points)

 

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)

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

            Late submission of softcopy 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.