Lab #2 Assignment
CSE 1320-002
Spring 2012
Design Document Due Date: February 21, 2012 at noon (12pm)
Lab Due Date: February 28, 2012 at noon (12pm)
(see instructions on website for how to turn this in - Ōlab submission infoĶ)
Grade value: % 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–4 and parts of later chapters in Foster and Foster as covered in class. It is assumed that the student is familiar with the programming concepts but not the C syntax. 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
One-dimensional Array
Multi-dimensional Arrays
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: For the rest of the semester you will be trying to determine a price to charge for an event and other data based on the venue size (number of seats), the fixed event costs, the amount of tickets you expect to sell, some profit margin, and other criteria. You will also make various other calculations as required. 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, structs, passing by reference (except arrays), or linked lists. You should do input and output using printf and scanf (you are allowed to use getchar and putchar if desired.)
Assumptions for the lab #2:
1) Strings will be single words with no blanks and the maximum length will be 40 chars. Use constants to define the max value.
2) The maximum number of different kinds of seating in a venue for Lab #2 is 3. Use constants to define the max value.
3) You will have a maximum of 5 venues for Lab #2 and a maximum of 4 events. These values will change in later labs.
4) For date checking in Lab #2, you may make the simplifying assumption that all months have 30 days. This will change in later labs.
Problem: The data in your database will be venues for events, event information, profit goals, and more. As part of this assignment you will have to find real data about some venues and events 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 venue and event information that you have researched to use as your test data. After getting all the input data 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) Print all of part of the data in a table
B) Calculate
i. Best venue for an event
ii. Cost to set for ticket prices
C) List all the venues that meet certain criteria
i. Less than given usage cost per hour
2) End the program
Data Description: For lab #2, you will be storing the input data in some single arrays and some multi-dimensional arrays.
The data elements and descriptions are given below. Following this first list, the data elements are described by type.
1) Venue code - a four digit integer where the digits represent a venue location using the guidelines given at the end of the assignment.
2) Venue name – a single word with no blanks and less than 40 characters long that gives the venue name. In lab #2 we are using strings for the name but we are making the string input simpler by insuring that all strings are one word, i.e. College_Park_Center is one word because there are underscores instead of blanks.
3) Venue type – a letter representing the type of venue. Choices are:
B Basketball arena
T Theater
A Auditorium
F Football stadium
C Concert hall
L Large room (seats > 150)
S Small room (seats <= 150)
O Outdoor performance area
M other miscellaneous type of venue
4) Venue kinds of seating (festival, selected, special) – an integer of either 1, 2 or 3 followed by that many letters of either F, S, or P. Must offer either festival or selected seating at a minimum. The number represents how many types of seating are available and the letter code(s) indicate which kinds of seating they are. Festival seating is seats that are not specifically assigned, selected means the seats are assigned in some way, and special is any other type of seating which could include lousy seats like in the high balcony or good seats like boxes.
Ex: 2 F P
5) Venue amount of seating of each kind – same number of values as previous info giving a list of number representing seats of the available types. Ex: for example above, 400 100
6) Venue cost per hour – a floating point money amount that is the amount that the venue charges per hour. Ex: 500.00 to represent $500.00 per hour
7) Event date – Event date as day, month, and year - three separate numbers
8) Event type – a letter representing the type of event. Choices are:
S Sports
A Arts and entertainment
C Community
P Public welfare
G Group participation
O Other
9) Event setting (intimate, average, large, mass) – they are ranges of performance preferences for audience size. This will help select among venues if needed. This is a letter representing one of the four setting sizes: I intimate (less than 300 people), A average (300 – 999 people), L large (1000 – 3999), M mass (4000+)
10) Fixed event cost – A floating point money amount that is the fixed amount charged for the performance/event
11) Event length in hours – An integer (must be > 0)
12) Desired profit percentage – A floating point number representing how much profit margin is desired. 33% is 0.33 (can be 0)
13) Desired profit fixed amount – A floating point number (can be 0) that indicates a specific dollar amount of profit desired.
14) Percentage of kinds of seating expected to sell – Ticket types within any one kind of seating are discounted and regular. The values for this input are two floating point numbers representing how much of each kind of seating you expect to sell. Ex: 1.00 0.75 would indicate 100% of discounted seating is expected to be sold and 75% of regular seating.
15) Chosen venue for event – this will be the venue code of the venue where the event will be held.
16) Recommended ticket prices – (up to 6 different values) – this value will be calculated and should be stored as floating point numbers. The possible combinations are discounted Festival seating, regular Festival, disc. Selected, reg. Selected, disc. sPecial and/or reg. sPecial.
17) Count of venue entered – integer that is the number of venues the user entered data for. Max is 5. This number is determined by user input.
18) Count of events entered – integer that is the number of events the user entered data for. Max is 4. This number is determined by user input.
The format for each piece of data is listed below.
Overall you are required to use at least four multi-dimensional arrays (data content and sizes will be specified for each one), one array holding words (strings), at least two one dimensional arrays, and then enough one dimensional and multi-dimensional arrays to hold the remaining data. [OK, this isn't as confusing as it seems. J]
As an example, letÕs say the user is going to enter two venues and one event. The first venue will be UT Arlington College Park Center (code 101 or 0101) and the second venue will be Bass Hall (code 221 or 0221). The event will be a concert. For each venue you will be asking the user for all the data about the venue and then storing this data into the arrays. In the two dimensional arrays, all the data for a single venue will be stored on the same row. The columns will represent different pieces of data about the venue in that array. In the string array, the name of each venue will be on the same row as in the other arrays.
You will have a maximum of 5 venues for Lab 2 and a maximum of 4 events. This information then dictates the sizes of the various types of arrays you will need. You will create 6 multi-dimensional arrays, including an array of strings, and 3 one-dimensional arrays. Some of the arrays hold integer data and some hold float data. Each column then in the float and integer arrays will indicate a different piece of data about the venue or event. In the string array, the name of each venue will be on the same row as in the other arrays. In the two character arrays, the same row always refers to the same venue. For the float and integer arrays, the number of columns is determined by how many pieces of data have to be stored. The number of rows is the same as the maximum number of venues that can be stored. (5 for this lab)
Out of the 6 total multi-dimensional arrays, there are three multi-dimensional arrays that will be used for more complex data structures. Another multi-dimensional array will hold the strings. Another holds the rest of the integer data and the last holds the remaining float data. These arrays are specified in detail below.
The integer array will have 5 rows and 6 columns. The array has 5 rows because that is the max number of venues or events and it has 6 columns because there is 1 piece of integer info to be stored for each venue and 5 pieces for each event. It is recommended that you create a set of constants to use for your column indices in the integer and float arrays, e.g. VCODE = 0, EVDAY = 1, EVMO = 2, EVYR = 3, EVLEN = 4, and EVENUE = 5e.g. for integers and for floats VCOST = 0, ECOST = 1, PROFITP =2 and PROFITA =3, and then use them as the indices for your arrays, ex.venint[4][EVDAY] would be the location of the event day of the 5th event in the integer array and venint[k][VCODE] would be the k+1th venue code in the array. Remember with C arrays you start counting at 0, so 5 venues means 0 to 4.
The float array venfloat will have 5 rows and 4 columns and will hold the venue cost, event cost, profit percentage and fixed profit amount. Use the constants described previously.
The char array venchar will be 5 by 3 and will hold the venue type, event type, and event setting. Create constants as described above.
There are two two-dimensional arrays holding more complex data. The first is an array of character data that represents the kinds of seating available in the venue. There are a maximum of 6 venues and each venue can have a maximum of 3 different types of seating. Therefore the venseating array will have 6 rows and 3 columns. The value in this array should be initialized to some default character that is not one of the valid choices for kinds of seating. Then, based on use input, the actual kinds of seating will be stored in this array. A venue may have 3 kinds of seating (F=festival, S=selected, P=special), or only 2 kinds of seating out of those three or only one kind of seating. All non-used values in the array will contain the default character. As an example, you might imagine that College Park Center (CPC) only has S and P seating, while Levitt Pavilion has only F seating, and the Fort Worth Botanic Garden has F, S, and P seating at its Concerts in the Garden. (Festival seating means no assigned seats, Selected means assigned seats, and sPecial means any unique type of seating like box seats or premium floor seats.) You might imagine that venseating array with the data above looks like this in memory:
S |
P |
|
F |
|
|
F |
S |
P |
|
|
|
|
|
|
The second two-dimensional array is also related to the kinds of seating in the venue. This data is a set of integers representing the number of each type of seating. The array is the same size as the char array and any place there is a char in the venseating array there will be a corresponding integer in the venamount array which indicates how many of those seats are available. So for CPC there might be 6200 Selected seats and 1000 sPecial seats.
6200 |
1000 |
0 |
875 |
0 |
0 |
1200 |
800 |
200 |
0 |
0 |
0 |
0 |
0 |
0 |
There is one four-dimensional array. This array has 5 strata (venues) with 3 layers (kinds of seating) with two rows(discount and regular) and two columns (expected percentage of occupied seats and cost per seat/price). Use the constants OCCUPIED = 0 and PRICE = 1. Remember with C arrays you start counting at 0, so 5 venues means 0 - 4 and 3 kinds of seating means 0 - 2. Declaring two constants DISCOUNT = 0 and REGULAR = 1 might also help. Ergo, venseatfloat[2][0][DISCOUNT][OCCUPIED] would be the expected percentage of the discounted seats to be occupied of the 1st kind of seating of the 3rd venue, i.e. the percentage of the discounted Festival seating at the Fort Worth Botanical Garden that is expected to be occupied.
[ If the four dimensional array messes with your mind, you can create two three-dimensional arrays instead venseatoccupy and venseatprice. You would use venseatoccupy[2][0][DISCOUNT] to store the data above and then venseatprice[2][0][DISCOUNT] would store the cost for the same seat. ]
The multi-dimensional array for strings will store one string per row. The string array will have 5 rows and 40 columns, venname[5][40]. You will be using entire rows of the array rather than single characters, i.e. venname[k] will be the string that contains the name of the kth venue. Make sure to declare all your constants (such as max string length) before you try to use.
Detailed descriptions of each data value. The data values below must be stored as described. You may also store additional values into these arrays if desired. In the descriptions below count represents the either the venue count or the event count depending on which kind of data is being entered:
Venue data:
Count of venues entered – integer that is the number of venues the user will enter data for. Max is 5. This number is determined by user input. This should be error checked and then stored as an integer variable.
Venue code - a four digit integer where the digits represent a venue location using the guidelines given at the end of the assignment. You will have to validate the digits of any code entered by the user. For the first venue, the venue 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 integer multi-dimensional array at the VCODE index on the correct row for this venue, i.e. venint[count][VCODE] where count represents the count +1 venue being entered.
Venue name – a single word with no blanks and less than 40 characters long that gives the venue name. The string will be read in with the %s specifier in a scanf statement 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 venname[count] in the multi-dimensional array.
Venue type – a single character representing the kind of venue. It must match one of the valid venue type codes. If it is valid, it should be stored in the array venchar[count][VTYPE].
How many kinds of venue seating – an integer of either 1, 2 or 3. This value may be stored but is not currently included in the data structures. It could be added to venint if desired.
Venue kinds of seating – 1, 2 or 3 letters of either F, S, or P. Must include either F or S at minimum to be valid. The number of letters is determined by the How many value just described. The letters that are read in are stored in venseating array. If two letters are entered for the venue at count, then the first letter is stored at venseating[count][0] and the second is stored at venseating[count][1].
Venue amount of seating of each kind – same number of integer values as previous info giving a list of number representing seats of the available types. The number of values is determined by the How many value just described. The values that are read in are stored in venamount array.
Percentage of kinds of seating expected to sell – 2, 4, or 6 floating point values representing how much regular and discounted seating you expect to sell within each kind of seating for a venue. The number of percentage values is determined by two (2) times the How many value just described. If there are 3 kinds of seating there will be 6 percentage values. If there is only one kind of seating there will be 2 percentage values. Values are given as discounted and then regular in same order as seated types. Ex. For kinds of seating of S P, then there will be four percentage values ex. 1.00 0.75 0.9 0.6 which would represent 100% of discounted Selected seats, 75% of regular price Selected seats, 90% of discounted sPecial seats, and 60% of regular sPecial seats. This data is stored in the venseatfloat array. Ex. the first value above would be stored in venseatfloat[count][0][DISCOUNT][OCCUPIED] . Note that the first two indices [count][0] are exactly the same as the two indices used in the venseating and venamount arrays.
Venue cost per hour – a floating point money amount that is the amount that the venue charges per hour. This value is stored in the floating point multi-dimensional array at the VCOST index on the correct row for this venue, i.e. venfloat[count][VCOST] where count represents the count +1 venue being entered.
Event data:
Count of events entered – integer that is the number of events the user will enter data for. Max is 4. This number is determined by user input. This should be error checked and then stored as an integer variable.
Event date – Three integers representing the event date as day, month, and year - three separate numbers. These values are stored in venint[count][EVDAY] and then in EVMO and EVYR. The dates should be error checked. For Lab 2, if you want to simplify this error checking, you may make the assumption that all months have exactly 30 days.
Event type – a letter representing the type of event. It must match one of the valid event type codes. If it is valid, it should be stored in the array venchar[count][ETYPE].
Event setting – a letter representing one of the four setting sizes. It must match one of the valid event setting codes. If it is valid, it should be stored in the array venchar[count][ESETTING].
Event length in hours – An integer (must be > 0). This value is stored in venint[count][EVLEN].
Fixed event cost – a floating point amount (must be >= 0). This value is stored in venfloat[count][ECOST].
Desired profit percentage – a floating point number between 0 and 1 inclusive. This limits the profit to 100% of the cost, i.e. if the cost is $5000 then the whole event should raise $10,000 to pay the cost and make 100% profit. This value is stored in venfloat[count][PROFITP].
Desired profit fixed amount – A floating point number of dollars (must be >= 0). This indicates that the user cannot plan to lose money on the event. This value is stored in venfloat[count][PROFITA].
Chosen venue for event – integer venue code of the venue where the event will be held. Store in the integer array at venint[count][EVENUE] . This is determined by the program and stored.
Recommended ticket prices – 2, 4, or 6 floating point values representing the price to set for each kind of available seating. This value will be calculated and should be stored as floating point numbers. If there are 3 kinds of seating there will be 6 prices. If there is only one kind of seating there will be 2 prices. Values are given as discounted and then regular in same order as seated types. Ex. For kinds of seating of S P, then there will be four prices calculated representing discounted Selected seats, regular price Selected seats, discounted sPecial seats, and regular sPecial seats. This data is stored in the venseatfloat array. Ex. the discounted Selected price would be stored in venseatfloat[count][0][DISCOUNT][PRICE] . Note that the first two indices [count][0] are exactly the same as the two indices used in the venseating and venamount arrays.
Input Implementation: For Lab #2 the user must enter at least 2 venues and no more than 5 and at least 1 event and no more than 4. Since the user has a choice, then the first piece of data that the program needs from the user are counts of how many venues and events they are entering. The program should check to make sure this counts are appropriate. [Note for development: start with a smaller number of events then increase to the required minimum when program is working well.] If the userÕs number exceeds the max, the program should inform the user of the maximum number of inputs allowed and have them reenter the count. Then your program must loop for the maximum of venue or event number of times (num= 0, 1, Émaxnumber-1 where maxnumber is venue count or event count whichever is greater) to read and store input. You also have the choice to make two separate loops; one to enter all of the venue data for all venues and then one to enter all event data for all events.
For Lab #2, 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 event on one line. The two forms of the input are described below. After getting the count of events 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:
Within a loop that will run for num times:
If the value of num is less than the venue count:
a. Ask the user for the venue 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 integer array at the correct row [num] at column VCODE. As an example of an explanation, you might tell the user "Please enter a venue code. Codes should be four digits with the first two digits representing the city and the last two digits representing a specific locationÉ" and then you can list the cities and venues for them to use. See the Miscellaneous section at the bottom for the venue code info.
b. Ask the user for the venue type letter and give them the choices. Check to make sure it is a valid type. Store this valid character in the char array venchar[num][VTYPE].
c. Ask the user how many kinds of venue seating there are and check that they enter only 1, 2 or 3. Store the number of kinds of seating either in an array location or in a temporary variable.
d. For each kind of seating, loop and do the following (the loop counter should be less than the how many kinds of seating):
1. Ask the user for a letter representing a kind of seating at the venue and give them the choices. Check that they entered a valid code letter and also check that they have not already entered this kind of seating for this venue. If valid, then store it at venseating[num][loopcounter] .
2. Ask the user for the amount of that kind of seating available at the venue. Check that they entered 0 or a positive number and then store it in the array venamount[num][loopcounter] .
3. Tell the user that 15% of the seats just entered will be priced as discounted tickets. Ask the user what percentage of discounted seating you expect to be occupied, i.e. sold. Check that this is a floating point value between 0 and 1.00 and store in venseatfloat[num][loopcounter*2][DISCOUNT][OCCUPIED] .
4. Tell the user that 85% of the seats just entered will be priced as regular tickets. Ask the user what percentage of regular seating you expect to be occupied, i.e. sold.. Check that this is a floating point value between 0 and 1.00 and store in venseatfloat[num][loopcounter*2+1][REGULAR][OCCUPIED] .
e. Ask the user for the venue cost per hour. Check for validity and save this value in the float array venfloat[num][VCOST]
If the value of num is less than the event count:
f. Ask the user for the month, day, and year for the event. 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 integer array at venint[count][EVDAY] and then in EVMO and EVYR
g. Ask the user for the event type letter and give them the choices. Check to make sure it is a valid type. Store this valid character in the char array venchar[num][ETYPE].
h. Ask the user for the event setting letter and give them the choices. Check to make sure it is a valid type. Store this valid character in the char array venchar[num][ESETTING].
i. Ask the user the length in hours of the event. Check that the data is valid and store in venint[num][EVLEN].
j. Ask the user for the fixed cost of the event. Check for valid data and store in venfloat[num][ECOST].
k. Ask the user for the desired percentage of profit to make from the event. Check for valid data and store in venfloat[num][PROFITP].
l. Ask the user for the desired fixed amount of profit to make from the event. Check for valid data and store in venfloat[num][PROFITA].
m. Ask the user for the single word name of the venue. Make sure to indicate that blanks are not allowed. Read it into a temporary string and check the length. If it is OK, store it into the name string in venname[num].
Line of data input method:
Your program may ask the user to enter all the information for one venue and one event on the same line. (or ask about venues first one per line then events one per line). The venue and event info would be all the pieces of data listed above. You must tell the user exactly how to enter the line of data.
The data for a single venue and event will be entered by the user as values on one line as follows {there must be one space only between the values}. Here's an example:
prompt> 0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Bluebonnet_Ballroom_UTA
which represents the UTA Bluebonnet Ballroom (code 0104, name Bluebonnet_Ballroom_UTA, Large room) with one kind of seating (Festival) and 400 total seats. 100% of discounted tickets are expected to be sold and 75% of regular price tickets. The hourly rental is $500. The event is on Feb. 24, 2012 and it is an Average sized, Group participation event. The event timeline is 7 hours, the fixed costs are $9600.00, the desired profit is 10% and $1000.
And a second example: [NOTE: this example is longer because the venue has two kinds of seating instead of one]
> 0221 T 2 S P 850 150 0.90 0.75 0.7 0.65 1200 5 3 2012 A L 12 47000.00 0.4 100000 Bass_Hall
which represents Bass Hall (code 0221, name Bass_Hall, Theater) with two kinds of seating (Selected and sPecial) and with 850 and 150 seats respectively. 90% of discounted Selected tickets are expected to be sold and 75% of regular price Selected tickets. 70% of discounted sPecial tickets are expected to be sold and 65% of regular price sPecial tickets. The hourly rental is $1200. The event is on March 5, 2012 and it is an Large, Arts and entertainment event. The event timeline is 12 hours, the fixed costs are $47000.00, the desired profit is 40% and $100,000.
Your program will read the first number and store it in the integer array at the correct location, then read and store the character into the corresponding location in its array, then read the third number, and so on. Your program should read all the numbers, chars, and the string within a single input command. Your program should read in as many lines of input for venues and events as were originally specified by the count up to the maximum of five lines of input.
Input verification:
When the user has entered count number of venues and events, print out all the input 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 arrays. It is also suggested that a small function be written which will print the name of a venue given the venue code as input. The function could have a switch or a bunch of if statements in it.
Task Description: (Menu-driven phase)
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) Print all the data for all venues
B) Print all the data for all events
C) Print all data for a single venue
D) Print all data for a single event
E) Determine the best venue for an event
F) Calculate price to charge for tickets
G) Find all the venues that cost less than a given amount per hour
H) End the program
The print functions let the user select to print one venue or event or all of them. These functions should call the function that is discussed in the input verification section above.
The determine-best venue function will look at features of the venue and the event to determine the best match. The best matching venue shall be stored with the event as the chosen venue. The decision procedure is:
Look at event setting, add up all the seating in the venue and compare:
If venue seating is less than minimum size of event setting,
then do not choose the venue
If venue seating is more than 50% larger than maximum event setting size,
then do not choose the venue
For venues the fit,
If event is Sports,
then venue must be B, F, O, or M type
If event setting is Intimate,
then venue must be T, A, C, L, or S type
If event type is Group Participation,
then do NOT choose A type
Else choose the first venue that matches size and doesnÕt violate any rules.
The calculate-price function has the following steps:
For each combination of regular and discounted tickets with a seating type, determine the expected number of tickets as:
the number of seats times the percentage of seats they expect to fill of that ticket type divided by 100 and save this value.
Ex: if there are 850 Selected seats, then 15% will be discount seats so 850 * .15 = 127. Out of those seats we expect to sell 90% of the tickets so 127 * .9 = 114. So we expect to sell 114 discount Selected seat tickets. All remaining calculations would be similar (850 – 127 = 723 regular seats, 723 * .75 = 542 which would be 75% of the regular Selected tickets) We will call these values: numRS for number of Regular Selected tickets,
numRF for Regular Festival tickets,
numRP for Regular sPecial tickets,
numDS for Discount Selected,
numDF for Discount Festival, and
numDP for Discount sPecial.
Once the ticket amounts are available, the ticket price is calculated as follows:
Add the fixed event costs plus (event length hours * venue cost per hour) to get total cost
Multiply desired percentage profit times total cost to get desired percentage amount
Add the total cost, the desired percentage amount and the desired fixed profit amount to get
profit plus expenses (P&E)
There will be a fixed ratio of ticket pricing as follows:
The basic ticket cost is considered to be the Regular Selected ticket cost (call this RS).
The price of a Regular Festival (RF) will be 50% of the RS price.
The price of a Regular sPecial (RP) ticket will be 300% of the RS price
Ticket discounts are: Selected (DS) 15%, Festival (DF) 30%, sPecial (DP) 5%
The total amount of money that is estimated to be brought in is the result of ticket sales. The equation is:
RS*numRS + RF*numRF + RP*numRP + DS*numDS + DF*numDF + DP*numDP
The num values will all be known or calculated from known values. The ticket prices are what we need to calculate. All the ticket prices are based on RS. So if we rewrite the equation in terms of RS we get:
RS*numRS + (RS*.5)*numRF + (RS*3)*numRP +
(RS*.85)*numDS + ((RS*.5)*.7)*numDF + ((RS*3)*.95)*numDP = ticket sales
The goal then is to find a value for RS such that ticket sales >= P&E while keeping the tickets within purchasing range.
If we collect terms in the ticket sales equation we get to:
RS*(numRS + (.5)*numRF + (3)*numRP + (.85)*numDS + (.35)*numDF + (2.85)*numDP) = ticket sales
Now we set this equation equal to P&E which is known and we can try to find a value of RS to make the equation work:
RS = (P&E) /
(numRS + (.5)*numRF + (3)*numRP + (.85)*numDS + (.35)*numDF + (2.85)*numDP)
If we can find RS, we now have the Regular Selected ticket price and all other prices can be calculated from that.
Once these values are calculated, they should be stored in the array.
The find-all-less-than-cost function should ask the user to enter an hourly venue cost for then go through every venue and print the complete information for all venues that have that have an hourly cost equal to or less than the userÕs entered cost.
When the user chooses "End the program" from the main menu, print a concluding message and then gracefully end the program.
***************************
You should design your program in advance before you begin writing code. In this lab and all other labs 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.
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, strings, passing by reference (except arrays), or linked lists.
Develop your program in small steps. Test and debug as you go.
Implementation Requirements:
For Lab #2 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 normally be turned in for the lab and a design will be required to be turned in for all labs after Lab 1. See the website or this assignment for the DESIGN DOCUMENT due date. It is usually ONE WEEK PRIOR to the lab due date.
A Lab #2 Design Document must be turned in in order for your Lab #2 assignment to be graded.
he program should use the following data structures:
Multi-dimensional integer, floating point and string arrays, single-dimensional character 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:
structs
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.
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 OIT how to use this function.
You must come up with information to use as test data for at least 3 venues and 2 events. You may only have one venue that has only one kind of seating - all other venues must have multiple kinds of seating. Please use real data for venues and events. Feel free to use venue websites to "plan" the event 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 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 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: (66%)
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!) (6 points)
Style (indentation, consistency, meaningful identifiers, lateral separation of code from line comments, etc.) (8 points)
Correct manipulation of the 2-dimensional char array (3 points)
Correct manipulation of the 2-dimensional integer and float arrays (6 points)
Correct manipulation of the 4-dimensional array (or the two three dimensional arrays) (5 points)
Correct manipulation of the 2-dimensional char array of strings (4 points)
Correct use of required control structures (6 points)
Correct function structure as required (8 points)
Proper implementation of data input and input error checking (8 points)
Output: (34%)
User clearly understands what is being requested for input (5 points)
Find-all tasks perform correctly (6 points)
Calculate 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)
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 pointer, structs or linked lists will result in 50 (fifty) point deduction per use [-50 deduction] (excluding passing arrays to functions which is allowed)
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:
Venue code structure: The code will be a 4-digit number. The leftmost two digits (1,000s place and 100s place) will indicate the city as follows:
01 Arlington
02 Fort Worth
03 Dallas
04 Irving
05 Plano
06 Garland
07 Grand Prairie
08 Carrollton
09 Other city in center of Metroplex
10 Other city on east side of Metroplex
11 Other city on west side of Metroplex
12 Other city on north side of Metroplex
13 Other city on south side of Metroplex
14 Other North Texas city
15 Other Texas city
20 Other US city
Following the city value will be a value in the 10s and 1s places that indicates one of the below. The codes for those digits will be:
01 College Park Center
02 Lone Star Theater
03 Texas Hall
04 Bluebonnet Ballroom
11 Levitt Pavilion
21 Bass Hall
22 Will Rogers Auditorium
23 Fort Worth Botanical Gardens
31 Myerson Symphony Center
40 Any other venue in DFW area
50 Any other venue in North Texas
70 Any other venue in Texas
90 Any other venue in the US
Therefore the venue code for the UT Arlington Bluebonnet Ballroom is 104 (or 0104 if you want) and the code for Radio City Music Hall in NY, NY would be 2090.
Sample input:
0104 L 1 F 400 1.00 0.75 500 24 2 2012 G A 7 9600.00 0.1 1000 Bluebonnet_Ballroom_UTA
0221 T 2 S P 850 150 0.90 0.75 0.7 0.65 1200 5 3 2012 A L 12 47000.00 0.4 100000 Bass_Hall
Your test data should be drawn from real venues and events. Go online and look up some locations and some types of events that occur there and use that for your data. Mix up the events and venues when you enter the data.