CST131 Exam #1
Write your three initials here: ____ ____ ____
(If you have no middle initial, make one up. If there is a duplicate letter, change it.)
RULES:
- Variable names:
- Use these three (different) letters as the variable names in your code, standing for the three inputs.
- COMMENTS [10% of grade]
- Be sure that every method (sub or function) begins with a comment that says what it will do.
- MODULARIZATION [15% of grade]
- Use methods (subs or functions, as appropriate) for all computations, inputs, and outputs.
In particular, your event handlers should NOT contain any of the following:
- The "Me" keyword.
- Output statements
- Input statements
- Calculations.
- Loops.
- ByRef and global declarations
- Avoid these unless they are absolutely required.
(ByRef is OK for an input method. Never for a function.)
Global declarations should not be needed for this program, at all.
Upload the two files as "xyz-exam1.vb" and "xyz-exam1.Designer.vb"
(where x, y, and z are YOUR initials).
Upload them as soon as possible, and upload them again from time to time, and when you are finished.
If you wish, you may name later copies as "xyz-1a", "xyz-1b", etc.
Make a copy of you final version, and name it "xyz-take2" (for the two files).
Work on it during the week, and submit your improved version next week, as a second exam
Now, for the specifications....
- Create a form with three textbox inputs, one listbox for multi-line output, and several buttons as described below.
- Label the inputs with your three initial letters, and add appropriate labels to the form (including a title at the top and your name in the lower-left corner).
- Give appropriate names to any "controls" (textboxes, checkboxes, etc.)
that will be mentioned in your code.
- Also add five checkboxes, labelled as follows:
- Multiples of 2
- Multiples of 3
- Multiples of 5
- Multiples of 7
- Multiples of 11
- Now, add buttons whose event handlers do the following:
(where X, Y, and Z stand for your initials.)
- ASCEND
- Rearrange the values in the three textboxes to be in "ascending order"
(from smallest to largest).
- DESCEND
- Rearrange the values in the three textboxes to be in "descending order"
(from largest to smallest).
- LIST FOR ALL
- Clear the output area, then list all integers from X to Y (one per output line), using a FOR/NEXT in your code (but NOT in the handler itself).
ALSO: After the list is complete, also state the count of items in the list, the total, and the mean average.
- LIST WITH LOOP
- Clear the output area, then list all integers from X to Y (one per output line), without using any FOR/NEXT statements in your code. (Use a DO/LOOP construct, instead.)
Also state the count, total, and average.
- LIST ODD
- Clear output, then list all ODD integers from X to Y.
You may use any kind of loop, but do not output even numbers
(regardless of the starting value for X).
Also state the count, total, and average.
- LIST BUT SKIP
- Clear output, then list all integers from X to Y,
skipping any numbers that are multiples of the the numbers indicated by the checkboxes.
i.e. if the third checkbox is checked, then skip multiples of 5 (but include 5 itself).
Also state the count, total, and average.
Your code should include a function similar to the following:
function idDiv( num as integer, facto as integer ) as Boolean
'==== Return true if num is divisible by factor.
Dim result as Boolean.
. . .
. . .
. . .
return result
end function
You might also want to start with something like this:
sub showall( . . .
'==== Show all values from X to Y
for j = x to y
say( j )
next j