Background:
My wife's recipe for trail mix calls for:
- 2 cups peanuts
- 2 cups raisins
- 1 1/2 cups M&Ms®
This makes (about) 6 servings.
Assignment:
Design an algorithm that adjusts the number of servings of Trail Mix and displays the adjusted recipe.
Implement your algorithm in a new project (within your existing CodeLite workspace).
Change the name of
main.cpp to
lab3A.cpp.
Change the code in
lab3A.cpp to declare a variable named
numberOfServings and adjust the recipe appropriately.
Try different values of
numberOfServings.
Examples
The following examples are correct execution. If
numberOfServings is set to
9.0, the output should be exactly as follows:
Recipe for 9.0 servings of Trail Mix:
3.0 cups peanuts
3.0 cups raisins
2.2 cups M&Ms
Changing the variable
numberOfServings to
4.0 (and re-compiling and running the executable) yields the following output:
Recipe for 4.0 servings of Trail Mix:
1.3 cups peanuts
1.3 cups raisins
1.0 cups M&Ms
After completing the program and testing the output for accuracy, make sure that you have a comment lines at the top of your file with your name, course and section, current date, and description.
Submission
Submit your source code using the
handin program. For
handin, for this lab, type the following in a terminal window exactly as it appears:
handin lab3A lab3A.cpp
To verify your submission, type the following in a terminal window:
handin lab3A
Rubric:
Points Item
------ --------------------------------------------------------------
10 Documentation
Header comment block at the beginning of each file with:
+ Your full name
+ Date(s) code was written
+ Description
Comments explaining the role of each variable and major section of code
40 Correctness
Program solves the assigned problem using methods described in program description
Program compiles without errors
Program executes without crashing
Program produces the correct output
------ --------------------------------------------------------------
50 Total