Lab Assignment # 1, CSE 1320
Section 501, Spring 2005
Due Date: Section 501 – Feb. 15tht, 5:30 pm
(see instructions on website for how to turn this in)
Topic objectives: Arithmetic
Control structures
Functions
1 - dimensional arrays
Programming style
School’s just getting started so you are already planning your vacation at Spring Break. In order to make your travel plans you’ve decided to write a program that will capture data about different vacations and will assess different aspects of each vacation to help you make the best choice based on your criteria. These aspects will include cost, location, length, type of accommodation, and type of transportation.
Since your finished vacation planner will probably be a big fancy system, you’ve decided to start by creating a system to calculate and compare the cost of a given vacation. You will enter the number of vacations to compare and for each vacation, the type of transportation and its cost, the type of accommodation and its cost, the average cost of one meal at the destination, and the number of nights you will stay at the destination. You will then calculate a total cost for each vacation. The following are the tasks you must do:
First you must create 6 arrays. The arrays must have at least ten elements but can have more. Each array will store a single type of data for a vacation. Each element of the array corresponds to a particular vacation in numerical order. E.g. The array element [1] would correspond to Vacation #1. The six arrays are:
Now you must print some sort of introduction for the user and then ask the user how many vacations 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 vacations instead of the required minimum of 5 to make it quicker to test. Then when it works, change it back to 5 vacations minimum.] You must ask the user for information for each array. For example, your program could ask:
After input is done, print out the data for each vacation 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 vacation 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 nights to stay
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 vacation
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 vacation 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 and minimum values 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 global variables 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.