In your cps006 directory, you should create a lab2 directory to work in. You will then copy several files into your lab2 directory to help you get started. Type the following unix commands from your account after you login (don't forget the trailing dot on the last line).
cd cps006 mkdir lab2 cd lab2 cp ~ola/cps006/lab2/* .If you did these commands correctly, typing pwd should show that you are in your lab2 directory, and typing ls should show the files Makefile, parts.cpp and pizza.cpp in that directory.
You might want to refer to lab1 for information on editing, compiling and running programs.
| 0 ^ |You can make a copy of the Eyes function in the file parts.cpp (don't destroy the old Eyes function). Here is the current Eyes function.
void Eyes()
// prints eyes of a head (corresponding to distance in Sides)
{
cout << " | o o | " << endl;
}
For example, the call NoseIn("oUo") should print the line
below
| oUo |
The user should be prompted for and input the width, height, and
thickness
in inches for a rectangular pizza (note that pizza.cpp
currently applies to a round pizza).
Output the price per cubic centimeter for the entire pizza and the volume of one slice. Note that the current SlicePrice function calculates statistics for a slice and for the entire pizza based on area, not on volume. You are to calculate a price based on volume. Assume that all rectangular pizzas have 16 slices. 2.54 cm = 1 in
Problems
1.The parts.cpp file contains the face drawing program given in
lecture.
Add to this program any TWO of the following functions:
drawing a
beard, drawing a hat, drawing eyeglasses, or drawing a
bow tie. Then
modify the main function to draw a new face that uses
the two
functions.
For example, your face might look something like the following
(feel
free to design your own glasses, hats and beards):
-\/-
/
\
/
\
-------------------
||||||||||||||||
|
|
| ____ ____ |
|--| o |-| o|--|
| ---- ---- |
_|
|_
|_
_|
| |______| |
|
|
|||
|||
|||
|||
\\\///
"CAUTION:" The "\" (backslash) character is a
special character. To
print one backslash you must use an escape sequence \\,
i.e., you
must put two backslashes inside of the double quotes to
print one
backslash. For example, to print three backslashes, you
must put six
inside the double quotes. For
cout << "\\\\\\" << endl;
the output will be:
\\\
2. Make a copy of the program parts.cpp called totem.cpp by using
the
unix copy command, type:
cp parts.cpp totem.cpp
Modify totem.cpp to print a totem pole of SIX heads of
which at least
three of the heads must be different. Here is an example
of a totem pole
of two heads. NOTE that your program must have a totem
pole of SIX
heads.
||||||||||||||||
|
|
| ____ ____ |
|--| o |-| o|--|
| ---- ---- |
_|
|_
|_
_|
| |______| |
|
|
|||
|||
|||
|||
\\\///
||||||||||||||||
|
|
|
|
| o
o |
_|
|_
|_
_|
| |______| |
|
|
|
|
Each lab is worth six points. A TA must check each of the points. It is your responsibility to ensure that a TA awards each point. After a lab is over you cannot receive credit for the first two points.
Use "submit_cps006 lab2 filenames" to submit your solution
This page can be found at http://www.cs.duke.edu/~zengh/cps06/assignments/lab2.html