CSC 230: The Week beginning Sep. 17
|
Reminder: Test on Friday!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Homework
Provide a brief definition of the following terms (in the interface
programming context):
- Loop
- Iteration
- Infinite loop
- Off-by-one error
If you use a source (book or web site), cite your source. (The sites
http://whatis.techtarget.com/ and http://www.webopedia.com/ are decent
sources for technical definitions.)
You must have a comment with your name
as well as meaningful control names.
Design a form like the one above that allows the user to
select and view a multiplication (times) table. One item from
the table is selected at random. Its answer is not shown in
the table but rather presented as a problem for the user to
solve. Your program should have
- The Form’s BackColor set to White and its Font Size set to 20.
- A label with some brief instructions.
- A NumericUpDown control that allows a user to select a variable
called Factor – it should be a number between 1 and 12.
- An OK button that when clicked:
- Displays the corresponding header image (TimesTable1.gif,
TimesTable2.gif, etc.) in a PictureBox.
(TimesTablesImages.zip)
- Choose a value for a variable QuizNumber at random – it
should be between 1 and 12.
- A ListBox displaying the selected multiplication table.
(The items must be added to the ListBox using a loop. You may
need to clear out previous results.)
- The answer to QuizNumber times Factor is not displayed in
the above list.
- A (quiz) label below the ListBox presents QuizNumber
times Factor as a problem for the user.
- A TextBox is provided for the user to make a guess at
the quiz question.
- A check Button allows the user to check his/her answer. If
the answer is correct, a Label with a smile face is displayed;
if the answer is incorrect, a frown face is displayed. (The faces
can be obtained by using the Wingding font.) Before
the check button is clicked and any time the answer is changed
a neutral face is displayed.
- A Clear Button empties out the PictureBox, ListBox, quiz
Label and answer TextBox. The face should be returned to neutral.
Due: Sept. 24
-
Monday
CalculateInterestZip.zip
(introduces NumericUpDown control and For-Next loop)
-
Wednesday
CrapsZip.zip
FibonacciZip.zip
-
Thursday
All Work and No Play
- Design a form like that above.
- When the user clicks one of the Before, During or After buttons, display
the corresponding image
(JackBefore.jpg,
JackDuring.jpg, and
JackAfter.jpg).
- When the user clicks the "See Jack Write" button, use a For-Next loop
to write hundreds of copies of the sentence "All work and no play makes Jack a dull boy." to
the textbox (which is multiline and scrollable).
Double Declining Depreciation
DoubleDeclining.exe
- Design a form like that above.
- Have the user enter the cost and salvage values in textboxes. Make sure they enter numbers and
that the cost is more than the salvage value.
- Have the user enter the lifetime (a number of years) in a NumericUpDown control.
- Make a loop that goes through the lifetime of the item (a For-Next).
- Within the loop, calculate the depreciation. The depreciation for a year is based on the
value at the beginning of the year times a fraction which has 2 as the numerator and the
lifetime as the denominator.
- Within the loop, calculate the new value which is the old value minus the depreciation.
- There is a tricky part near the end that sometimes occurs, the value cannot go below the
salvage value. Thus, if the above calculation results in a value lower than
the salvage, then
the value must be set equal to the salvage (and the depreciation must also be adjusted). If this
happens you might also want to get out of the loop, using the statement Exit For.
-
Friday
TEST 1.
LLBeanSweatersZip.zip