Lab Assignment # 1, CSE 1320-501, Spring 2004

 

Due Date:  Tuesday, February 17, 5:30 p.m.  (see instructions on website for how to turn this in)

 

Topic objectives:       Control structures

                                        Functions

                                        1 - dimensional arrays

                                        Programming style

 

You recently received a bunch of artwork as a gift.  Most of the pieces are paintings or drawings or other things that need to be framed and hung on the wall.  So you need to make a trip (or many trips?) to the framing store to have your new treasures prepared to be displayed.  But before you go, you want to figure out exactly the sizes you need for each item and then be able to figure approximate prices for the glass, the mats, and the frames given some prices for each type of item.  The following is an explanation of what you must do.

a)       First you must get one item of the artwork that needs to be framed. The user will need to enter some measurements about the item.  The height and width measurements refer to the H x W of the picture that the user wishes to see in the final framed piece.  (Something printed on 10” x 10” paper may only have a 5” by 6” image on it that the user wants to see.)   For each item the framing process will need a the image size, the width of the border of matboard to go around the image, the category of frame (1 – 4) [this determines the approximate cost], and the size of the piece of glass needed for the finished piece.

b)      The user enters the following data for the image to be framed:  height in inches as a floating point number, width in inches as a floating point number, width of the mat in inches float, and category of the frame as integer value 1 , 2, 3, or 4.

c)       Given the height, width, mat, and category, your program must calculate the following:

a.       For the matboard, calculate the outer height and outer width and calculate the height and width of the opening through which the image will show.  Print these values to the screen with a message telling what the values represent.

b.       For the glass, calculate the height and width needed and print this to the screen.

c.        For the frame, calculate the circumference of the finished item in linear inches and print this to the screen.

d.       Estimate a cost as follows and print it to the screen also:

                                                               i.      Matboard is .50 per square inch based on just the outer dimensions

                                                             ii.      Glass is .12 per square inch

                                                           iii.      The frame prices depend on category so

1.       Category 1 is .45 per linear inch

2.       Category 2 is .65 per linear inch

3.       Category 3 is .75 per linear inch

4.       Category 4 is 1.00 per linear inch

                                                           iv.      Total cost is matboard cost plus glass cost plus frame price.

d)      After the item has been priced, ask the user if they wish to continue entering additional items to be framed.  If yes, go back to step b), otherwise, print out the total number of pieces that were entered and the total sum of all the estimates that were calculated and the end the program.

 

 

Implementation requirements:

The program should use the following data structures:

Floating point variables for the size data

A float array to hold the 4 category frame prices

 

The program should use the following control structures:

A while or for loop to read in the individual inputs

Function calls to perform the tasks

If, if-else, or nested ifs to choose the appropriate action after an item is entered

 

The program should be implemented as a set of functions with at least one function for input, one for printing the sizes and one for calculating the 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 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, 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 using the sample data that is given below AND must be run using your own sample data as well.  The sample data set 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.  

 

Sample input values: 

For item 1:  Height is 10.25 inches, width is 8 inches, matboard is 3 inches wide, and frame is category 3

For item 2:  Height is 4 inches, width is 6.5 inches, matboard is 1.5 inches wide, and frame is category 4

For item 3:  Height is 30 inches, width is 24 inches, matboard is 4 inches wide, and frame is category 1

For item 4:  Height is 1.3 inches, width is .75 inches, matboard is 1 inches wide, and frame is category 3

For item 5:  Height is 5 inches, width is 5 inches, matboard is 3.2 inches wide, and frame is category 2

 

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 array  (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%)

                Each task performs mathematically correctly (3 points per task a., b,. c., d., d) )

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

                Output contains all the sample data and at least 5 more additional input items  (11 points)