Lab Assignment # 1, CSE 1320 Section
001, Fall 2005
Due Date: Section 001 – Sept. 19th ,
(see instructions on website for how to turn this in)
Topic objectives: Arithmetic
Control structures
Functions
1- dimensional arrays
Programming style
Ahhh! The spices of life. Isn't food better with the right spices? If you're a novice cook, then dry spices might still be things you are learning to work with in your cooking. This program is designed to help novice cooks by having them select a 'rack' of spices, choose quantities, and record costs. With this rack of spices then the novice cook will determine what kind of seasoning blends they can make and will record this info for later use. The cook will also track the cost of each seasoning blend and will determine combinations of blends available with the given quantities of spices. The program will allow the cook to print out the spice rack contents, quantities and costs and to printout possible seasoning blends that could be made.
Below you will find a list of spices. Use this as the starting point for the list of possible spices your novice cook can select from. The cook must have at least 20 choices and must pick between 10 and 15 spices for the spice ‘rack’. The user will select spices from your list by number for their rack. After they have selected their spices, then you must go through the spices one by one and collect data. The possible spices must include:
Garlic
Oregano
Onion
Sweet paprika
Dry mustard seeds
Black pepper
Rosemary
Salt
Basil
You should number the spices so that the cook can select by number. You may organize the spices in any order.
One the novice cook completes their ‘rack’ of spices the program should go through each of the selected spices in the rack one by one and get the following information from the user.
Quantity available of the spice in standard units (ounces or milligrams as you prefer. )
Total cost for that quantity of spice (i.e. 7mg of garlic
might cost $0.77 or $0.07 or $1.40 for example)
The program should store the available quantity for each spice and the cost for ONE unit (ounce or milligram) of that spice. After all the data has been entered, the program should print a list of the spices in the spice rack by name, the quantity (in appropriate units), the cost per one unit of spice and the total cost for the available amount for each of the spices in the ‘rack’.
Now, with the spices in the spice ‘rack’, the program will let the user determine what types of seasoning blends can be made. Below are three seasoning blends. Each lists the spices in the blend and the RELATIVE quantities needed of each. You must use the three blends below and come up with at least two more (yes you can find this stuff on line). Give the novice cook the five seasoning blend choices. The cook will select a blend and your program must determine a) if the blend can be made with the available spices, b1) if yes, the maximum number of units of the blend that could be made from the available spices and the price per unit of blend, or b2) if no, what parts of the blend are missing (i.e. which spices are there insufficient amounts of?) For the blends below “unit” means either ounce or milligram to match whatever units you have used previously. The given blends are:
Italian Seasoning Blend (requires 27 units of spices total for one mixture)
5 units basil
4 units marjoram
5 units oregano
3 units coriander
4 units thyme
2 units rosemary
4 units sage
Indian Seasoning Blend (requires 5 units of spices total for one mixture)
1 unit cumin seeds
1 unit fennel seeds
1 unit mustard seeds
1 unit black cumin seeds
1
unit fenugreek seeds
Cajun Seasoning Blend (requires 26 units of spices total for one mixture)
16 units sweet paprika
2 units black pepper
3 units cayenne
1 unit garlic
1 unit onion
1 unit salt
1 unit rosemary
1 unit oregano
You must add two more seasoning blends with at least three ingredients
each. Display the seasoning blends to the
novice cook and let the cook choose a blend.
Your program must do the following steps for the chosen blend of
seasoning:
a) Determine if the blend can be made from the available spices by the steps below:
i) Determine if all the required spices are in the spice ‘rack’. If not go to step b2.
ii) If all spices are available determine if the required amount of each spice is available by:
1) Find the ingredient requiring the smallest number of units (ex: for Italian blend this is rosemary)
2) Determine if the amount available in the spice rack is sufficient for the blend. If not go to step b2.
3) Repeat steps 1 and 2 for each ingredient in the seasoning blend
4) If sufficient amounts of all spices are available to make the blend go to step b1.
b1) Since at least one mixture of the blend can be
made your program should do two things.
First, calculate the cost of one mixture of the seasoning blend and
print this. Second, repeat
the steps 1 -4 above for double the amount (two mixtures of the blend). If two can be made,
check for triple the amount (three mixtures) and continue checking in this
fashion. When your program finds an amount that is too large, stop checking and print a
message indicating how many mixtures of the required blend can be made.
b2) If your program has reached this step, then
either some required spices are missing for the blend or the required amounts
are not available. Print a
message indicating which spice was found first to be missing or
insufficient for the blend.
Once your program has determined the availability of spices for a chosen blend, allow the user to either choose another blend to check or to end the program. If the user is finished, print a concluding message and then end the program.
Implementation
requirements:
The program should use the following data structures:
One dimensional integer array for recording spices chosen for the spice ‘rack’
One dimensional floating point arrays for recording corresponding amounts in units of spice and price of ONE unit of spice
One dimensional integer and floating point arrays to hold data for each seasoning blend: spice numbers and amounts in units
The program should use the following control structures:
Function calls to perform tasks
A while or for loop to perform testing for the spice blends
If, if-else, or nested ifs to print correct spice names with numbers in output
The program should NOT use:
structs
multiple dimension arrays
any topic not covered in class before the lab DUE date unless approved by the instructor
The program should be implemented as a set of functions with
at least one function
forgetting input from the user, one for printing the data, and one for checking
blends. 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 with three different sets of data for the
spice rack contents. The first data set
(dataset 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 three different times so that you have
a total of three different data sets. The sample datasets 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.
Spice Amount in
units Total
cost
Garlic 100 10.00
Oregano 25 1.25
Onion 40 2.15
Sweet paprika 5.5 5.50
Dry mustard seeds 10 0.10
Black pepper 108 2.16
Rosemary 10 2.40
Salt 200 1.00
Basil 22 3.30
Your1: 10 4.00
Your2: 33.3 6.00
Your3: 5 5.55! p>
Your4: 1 3.85
Your5: 10 2.39
! o:p>
Grading scale:
Code: (48%)
Program header and function headers for all functions (8points)
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!) (8 points)
Style (indentation, consistency, meaningful identifiers,
lateral separation of code from line comments, etc.) (8 points)
Correct manipulation of the
1-dimensionalarrays (8 points)
Correct use of required control structures (4 points)
Correct function structure as required (4 points)
Proper implementation of input error checking (8
points)
Output: (52%)
User clearly understands what is being requested for input (5 points)
Cost per unit task performs mathematically correctly (4 points)
Determination of missing
spice for blend done correctly (6 points)
Determination
of insufficient spice for blend done correctly (8 points)
Determination of total
available mixtures for blend done correctly (12 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
(12 points)
Deductions:
Use of global
variables will result in an overall grade of 0 (zero)
Use of the exit command will result in an
overall grade of 0 (zero)
Use
of structs, multiple dimension arrays, and/or switch statements will result in a 20 (twenty) point deduction
per use
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.