We're going to give you two projects to work on in this lab. The projects are stored in a zip archive so you will have to use a special program to extract them. Download a ZIP'ed copy of the Lab 5 projects and store it in the c:\files directory.
Use PowerZip to open this archive and then to extract the files to the c:\files directory. You should be able just to double click on the archive icon in the c:\files window to run the program PowerZip from the start menu. Using its menu set the download directory to c:\files and hit the extract button to create:
The driver program Main2D.cpp
uses the EzWindows library to sequentially plot five functions that
you will write.
You should not modify Main2D.cpp in this lab.
However, you are encouraged to look at it to learn a bit more about
C++ and EzWindows.
The program you will modify is called
Funky.cpp.
Presently, this program contains five simple functions similar to:
The values returned by these functions produced the boring output that
you saw when you ran the program.
You are to replace these five functions with five functions that
return the following values:
You will need to use functions from the math library to write the
functions described above. Notice that the file cmath
is included in funky.cpp, this is the "include" file for the math
library.
Start up Visual C++ and open the workspace
c:\files\lab05\Color100\Color100.dsw. This workspace
should contain three files
The driver program Color100.cpp
plots four functions that you will write.
You will use the mouse to move between these functions by clicking on the
graphics window.
"Templates" for the four functions you will modify are found in Funky.cpp. These functions receive
two constant integers as inputs and return an EzWindows color. The
driver function will divide the screen into 100 squares, 10 on each
side. These squares will be addressed by their x and
y co-ordinates, integers from zero to nine. Your program
will be called with each of the 100 possible co-ordinate pairs and
will be expected to return a color for the corresponding squares.
Examine Funky.cpp and then build
and execute Color100 to learn a bit more about the process.
float MyFuncN(const float x)
{
return N*x ;
}
Your task
-x, if x is negative,
and x, if x is positive
0, if x is zero
Go into a for-loop,
and execute z = z*z
10 times.
In a second for-loop,
execute z = sqrt(z)
10 times.
Return z as the result of your function.
Lab instructor check-off 1
Once you've got the five functions plotted, show your work
to the lab instructor.
Conditional statement execution
Your task and your instructor's checkoff
You are to write
four functions that do the following:
0
Returns Red
, if x > y;
White
, if x equals y; and
Blue
, if x < y
1
Returns values that cause the window to resemble the flag of Ireland
(three vertical stripes: green, white, and red) or any other European country.
2
Returns values that cause the window to resemble the flag of
the state of North Carolina, but without the seal.
3
Returns values that cause the window to resemble the flag of
the United States, but without the stars.
Return to CSCI 201 page
Return to the UNCA Computer Science home page