Homework 5 - CS Course Webpages

advertisement
(Print this page as a cover sheet for your printouts)
LAB 5 (COMPLETE)
Section: ENGR 112-______________
Due: 11:59 P.M. Thursday, April 10, 2008
"On my honor, as an Aggie, I have neither given nor received any unauthorized
aid on any portion of the academic work included in this assignment."
________________________________
Typed or printed name of student
________________________________
Signature of student
NOTE: Please follow your lab instructor's directions for submitting your
assignment through CSNET. ONLY ASSIGNMENTS SUBMITTED TO CSNET WILL BE
GRADED! Make a printout of each source file and staple it behind this cover
sheet, unless your lab instructor directs otherwise. Sign it and give it to
your TA in lab or put it in your TA's mailbox in the corner of the 3rd floor
of HRBB, near room 312. IF YOU DO NOT TURN IN A SIGNED COVER SHEET YOUR WORK
WILL NOT BE GRADED!
The grade for this lab will be based on style (formatting, variable names,
comments, etc.), syntax (no compilation or link errors), and correctness
(passes all test cases). Your grade for this lab is:
Problem #
1
2
3
4
5
6
Style
/3
/6
/7
/1
Syntax
/3
/6
/7
/1
Correctness
/9
/13
/16
/3
----------------------------------------------------------Total
/15
/15
/15
/25
/30
/5
Grand total _____/100
(Print this page as a cover sheet for your printouts)
1. (15 points) Define the terms in section 9.11. Type up your words and
definitions as a text file named glossary9.txt. After each definition put the
source (textbook page number, URL on the web, etc.) Note: If you use a word
processor such as Microsoft Word, do Save As > Plain Text.
2. (15 points) Do the same for the terms in section 10.13 and name your file
glossary10.txt.
3. (15 points) Write an FLTK C++ graphics program which draws the Olympic
banner vertically like this:
on a white background, using Line_style to make the circles thick enough (see
section 12.7.7). Name your program olympic.cpp. Hint: Start with
sample_main3.cpp (on the web page) and modify it. Note: Don't worry about
interlocking the circles. [Trivia: The reason for these 6 colors (counting
white too) is that they are sufficient to draw the flag of every nation in the
world, at least as of 1931!]
4. (25 points)
Write an FLTK C++ graphics program which draws the Texas flag:
with the correct proportions, namely, each rectangle should be twice as long as
it is wide. Name your program texas.cpp.
5. (30 points) Write an FLTK C++ program to display (approximately) the phase
of the moon on any day of the lunar month as a picture of a yellow moon on a
black background. Day 0 (0 days after new moon) is just a yellow circle, i.e.,
the "inside" of the moon is dark. Day 4 should resemble this:
Day 15 is full moon (solid yellow) and then earth's shadow passes to the other
side, i.e., day 25 should resemble this:
with Day 29 only a tiny sliver. To simplify the program, make earth's shadow
two black squares which slide across the moon, e.g., if r is the moon's radius
then the two black squares are moved (2 * r * days / 15) to the left from this
position:
for days running from 0 to 29 (number of days after new moon). Your program
should begin by asking for a double from the console (number of days since new
moon) and then display the moon with text "xx days after new moon". Name your
program moon.cpp.
OPTIONAL EXTRA CREDIT
6. (5 points) Modify program 5 to first display the new moon and then each time
the Next button is pressed add one to the day number and display that phase and
day number, up to 29. Name your program phaser.cpp.
Download