CS13 Calculator Project #3
Starting with the 2-input form you created for Calculator Project #2,
using "Visual Basic",
add a third input and the following buttons:
(Let a, b, and c represent the three inputs).
- SUM3 ' Sum all three values (a+b+c)
- MAX3 ' Compute the maximum of a, b, and c
- EVEN ' Determine whether or not a is even (divisible by 2)
- SUMRANGE ' Sum all integers from a to b
- SUMEVEN ' Sum all even numbers from a to b
- SUMMULT ' Sum all multiples of c from a to b
- FACTOR ' Is "c" a factor of a?
- PRIME ' Does a contain a prime number?
(i.e. Does it have any factors between 2 and a-1 ?)
Following ia a useful function for determining
whether or not one number is a factor of another.
Function isFactor( number as Integer, factor as Integer) as Boolean
'''' Is c a factor of a ?
'''' Return true if c divides evenly into a, with no remainder.
Dim yesno as Boolean
if (a mod c) = 0 then
yesno= true ' Remainder is zero - it IS a factor.
else
yesno= false
end if
return yesno
End Function