|
I'm not sure whether it's ok for students to be posting questions in here, but if it is...
I have this assignment due this week where I'm supposed create a console to calculate a factorial. I think I said that right:)
Here is the code I came up with:
Module Module1
Sub Main() Try Dim strInput As String Dim intAccum As Short = 1 Dim intIndex As Integer
Do Until IsNumeric(strInput) = True Console.WriteLine("Please enter a number") strInput = Console.ReadLine() Loop
Dim intInput As Double intInput = Val(strInput)
While intInput > 0 Console.WriteLine("") Console.WriteLine("Num" & vbTab & "Num!")
For intIndex = 1 To intInput intAccum = intAccum * intIndex Console.WriteLine(intIndex & vbTab & intAccum) Next
Console.WriteLine() Console.WriteLine("Please enter a number") strInput = Console.ReadLine()
Do Until IsNumeric(strInput) = True Loop
intInput = Val(strInput) intAccum = 1
End While
Catch ex As Exception MsgBox(ex.Message()) Finally 'MsgBox last index successfully used in factorial End Try
End Sub
End Module
First I'll say that my instructor gave us some psuedo to build from. The last line says "Create a msgbox to display the index last successfully used in the factorial calculation.
Maybe I'm making it too hard, but would someone be so kind as to tell me what that means and how to do it? I'm missing something, which makes it impossible to message and I have to have it to count the iterations for byte, short, etc.
Thanks, Todd
|