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:

  1. Type of transportation where the array element value will be: 0 = none, 1 = automobile, 2 = recreational vehicle (RV), 3 = tour bus, 4 = plane, 5 = boat, 6 = cruise ship, 7 = train, 8 = other
  2. Total cost of transportation to and from venue destination for one person stored as dollars and cents.  (xxx.xx)
  3. Type of accommodation where 0 = none, 1 = hotel, 2 = recreational vehicle (RV), 3 = tour bus, 4 = bed & breakfast (B&B), 5 = rental home, 6 = cruise ship, 7 = other.  However, if transportation code was 6 above then program should automatically assign 6 as the accommodation code and should assign a cost of 0 for accommodation cost and average meal cost without asking the user.
  4. Cost of accommodation for a single night for one person stored as dollars and cents
  5. Average cost of one meal at the destination as dollars and cents
  6. Number of people who will stay at the destination for 2 days and 2 nights
  7. Total cost per venue ( calculated by the program)

 

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 :

 

Ask similar questions for all of the data needed for each of the venues to be compared: type of transportation and its cost perperson, the type of accommodation and its cost per person per  night, the average cost of one meal at the destination, and the number of people. 

 

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:

  1. For each venue, calculate and print the total accommodation cost by multiplying the cost per one person times the number of people times 2 (it will always be two nights) and print this info with a label
  2. For each venue, calculate and print the total transportation cost by multiplying the cost per one person times the number of people and print this info with a label
  3. Calculate total average meals as follows:  average meal cost times (the number of people times (3 meals per day * 2 days) plus 2 * number of people).  Print this value with a label.
  4. For each venue, calculate total cost by adding transportation cost plus total accommodation cost plus total average meals.  Print these results and store them in the total cost array.
  5. Starting at the beginning of the array, find the maximum cost of any the venues on the list and print this value indicating which venue number it is.  Then using that maximum cost to compare with, find the next largest cost and print its venue number.  Repeat this until you have found the five most expensive venues. 
  6. Sum the five most expensive venues and then print the total revenue amount the musician would be paid (using the formula in the first paragraph) if all of the venues were played.

 

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.  

 

Sample input values for data set 1:   

Venue

Transportation type

Trans cost

Accommodation type

Acc cost

Avg meal cost

Number of people

1

car

40.00

hotel

120.00

8.00

10

2

cruise ship

1400.00

cruise ship

0.00

0.00

7

3

plane

448.12

B&B

72.00

12.00

8

4

none

0.00

rental house

400.00

85.00

14

5

tour bus

99.99

tour bus

10.00

3.50

9

6

RV

100.00

RV

0.00

25.00

3

7

train

250.00

none

0.00

13.00

15

8

tour bus

120.00

hotel

800.00

12.00

5

9

plane

162.18

hotel

423.88

56.00

2

10

car

240.00

B&B

52.00

17.50

8

 

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.