Lab Assignment # 1, CSE 1320
Sections 501, Summer 2005
Due Date: Section 501 – June 20th, 6:00 pm
(see instructions on website for how to turn this in)
Topic objectives: Arithmetic
Control structures
Functions
1 - dimensional arrays
Programming style
You have been hired to help work out schedules and concert costs for a famous musician. In order to do this, the musician and the manager will enter data about each possible venue that the musician could play, along with where they would stay, how many people would be included, type of accommodation and type of transportation. For any venue, the musician is paid 500% of the actual costs for transporting, housing and feeding the entire entourage for 2 days and 2 nights.
The final version of your system will compare venues and work out possible tour itineraries but to start with you will just build a program to decide on the top five most lucrative venues.
You will enter the number of venues to compare and for each venue, the type of transportation the musician would use to get there and its cost, the type of accommodation and its cost, the average cost of one meal at the destination, and the number of people who would be staying at the destination for two days and two nights. You will then calculate a total cost for each venue and the total amount the musician would be paid as described in the first paragraph. The following are the tasks you must do:
First you must create 7 one-dimensional arrays. The arrays must have at least ten elements but can have more. Each array will store a single type of data for a venue. Each element of the array corresponds to a particular venue in numerical order. E.g. The array element [1] would correspond to Venue #1. The six arrays are:
Now you must print some sort of introduction for the user and then ask the user how many venues they will be comparing. The minimum number is five and the maximum is the size of your arrays declared above (10 or larger if you made your arrays larger)
Next you must request data from the user to fill the arrays. [When testing you might make the loop shorter and enter only two venues instead of the required minimum of 5 to make it quicker to test. Then when it works, change it back to 5 venues minimum.] You must ask the user for information for each array. For example, your program could ask:
Please enter the type of transportation for venue # 1. Use the following codes to enter this data: 0 = none, 1 = automobile, 2 = RV, 3 = tour bus, , 4 = plane, 5 = boat, 6 = cruise ship, 7 = train 8 = other
Enter the code number for the type of transportation :
After input is done, print out the data for each venue to the screen.
After this you will perform the following calculations and output the results:
After this is done, your program must ask the user if they wish to run the venue comparison again and if so, go back to the beginning and request the user to enter new values for all data. If the user is finished, print a concluding message and then end the program.
Implementation
requirements:
The program should use the following data structures:
Integer array for transportation codes
Floating point array for transportation costs
Integer array for accommodation codes
Floating point array for single night accommodation costs
Floating point array for average meal costs
Integer array for number of people to stay
Floating point array for total cost
The program should use the following control structures:
Function calls to perform the tasks
A while or for loop to perform calculations and output for each venue
If, if-else, or nested ifs to check the transportation codes before asking accommodation / meal questions
The program should be implemented as a set of functions with
at least one function for
getting input from the user, one for printing the venue data, and one for
performing calculations. 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 data from the keyboard
Print the appropriate outputs
Let the user enter additional values until the user indicates that they are finished.
The program should have a program header which gives, at least, your name, an email address where you can easily be contacted, 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.
This program must be run with three different sets of data. The first data set (data set 1) should use the values given below. You must also create two additional data sets and run your program with them as well. You may run it three times within a single execution or you may execute the program two different times with one repeat within a single execution 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 after reviewing the instructions on the class website, it is your responsibility to ask the TA or OIT how to use this function.
Grading scale:
Code: (66%)
Program header and function headers for all
functions (8 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.) (10 points)
Correct manipulation of the 1-dimensional
arrays (10 points)
Correct use of required control structures (10
points)
Correct function structure as required (10
points)
Proper implementation of input error checking (8
points)
Output: (34%)
User clearly understands what is being requested for input (5 points)
Each task performs mathematically correctly (4 points per task 1, 2, 4.)
Maximum 5 values and total revenue are found correctly (4 points)
Output gives clear information to explain the values to the user (5 points)
Output contains all the sample
data and two additional data sets (8
points)
Deductions:
Use of
structs or multi-dimensional arrays will result in a 10 point deduction
Use of
continue will result in a 20 point deduction
Use of
a break outside of a switch statement will result in a 20 point
deduction
Use of
global variables will result in an overall grade of 0 (zero)
Use of goto or exit
will result in an overall grade of 0 (zero)
A program that
compiles with warnings or errors will result in an overall grade of 0 (zero)
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.