Code:

` Private operators() As String = {"-", "+", "/", "*", "^"}`

Public Function EvaluateExpression(ByVal expression As String) As Double

For i As Integer = 0 To operators.Length - 1

'Chose an operator to check

Dim sign As String = operators(i)

'Get the last instance of the operator

Dim lastPosition As Integer = expression.LastIndexOf(sign)

If lastPosition > -1 Then

'If there's an instance of the operator, then begin the recursion

Dim part1 As String = expression.Substring(0, lastPosition - GetSpacesBefore(lastPosition, expression))

Dim part2 As String = expression.Substring((lastPosition + 1) + GetSpacesAfter(lastPosition, expression))

'Calculate the left and right part of the expression based on the operator

If sign = "-" Then

Return EvaluateExpression(part1) - EvaluateExpression(part2)

ElseIf sign = "+" Then

Return EvaluateExpression(part1) + EvaluateExpression(part2)

ElseIf sign = "/" Then

Return EvaluateExpression(part1) / EvaluateExpression(part2)

ElseIf sign = "*" Then

Return EvaluateExpression(part1) * EvaluateExpression(part2)

Else

Return EvaluateExpression(part1) ^ EvaluateExpression(part2)

End If

End If

Next

'There are no operators, return the value

Return CDbl(expression)

End Function

Private Function GetSpacesBefore(ByVal index As Integer, ByVal input As String) As Integer

Dim counter As Integer = 0

For x As Integer = index To 0 Step -1

If input(x) = " " Then

counter += 1

Else

Return counter

End If

Next

Return 0

End Function

Private Function GetSpacesAfter(ByVal index As Integer, ByVal input As String) As Integer

Dim counter As Integer = 0

For x As Integer = index To input.Length - 1

If input(x) = " " Then

counter += 1

Else

Return counter

End If

Next

Return 0

End Function

Code:

`1 + -1`

With this being the math forum, I figured that I'd ask it here. How would I account for those two issues? ]]>

I'm sure it's going to be based on math.log10 function, but I don't know how... ]]>

Code:

`Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click`

Dim input As Decimal

If Decimal.TryParse(TextBox1.Text, input) Then

Dim denominator As Integer = 1

Do Until input Mod 1 = 0

input *= 10

denominator *= 10

Loop

Dim numerator As Integer = CInt(input)

Dim hcd As Integer = Enumerable.Range(2, Math.Min(numerator, denominator)).LastOrDefault(Function(x) numerator Mod x = 0 AndAlso denominator Mod x = 0)

If hcd <> 0 Then

Label2.Text = String.Format("Simplest Form: {0}/{1}", numerator \ hcd, denominator \ hcd)

Else

Label2.Text = String.Format("Simplest Form: {0}/{1}", numerator, denominator)

End If

End If

End Sub

can anyone tell me how to adjust for fractions such as 1/3 or 1/7? ]]>

One solution is to do it in linear fashion, so basically layout the entire surface area in points, so 100 x 60 would be a number from 0 to 5999.

That solves it without a problem, but I decided that I need a little variation in this, so another solution was do 2 random numbers, 0 to 99 and 0 to 59.

That second solution is the best for what I need, except I'm not a math expert so I wanted an opinion about this. If you have 2 consecutive random numbers from a set. So for example in the second example I would have 2 pairs. Then will the second pair still be derived from the first pair. I'm looking for a math function on this, because I can not plot the results in a process of elimination, or I get a variation in the length frequency.

Here is what I mean. I derive a pair 0 to 99 = 53 and 0 to 59 = 21 then in the second pair 0 to 99 = 11 and 0 to 59 = 40. If I add these to a table and randomly continue to generate pairs, then it will exhaust the table at random times, since most random number generators are very rough. This would give me a different average (frequency) every time.

So if I use the pair method, what would be the best way to go through the random numbers (is there a best way) and keep the frequency very tight for each evolution (complete table fill).

In case anyone is wondering, the reason the pair method works best for me, is the way I have updates running in a loop. This serves as a simulation and maybe later a game loop. ]]>

This is probably staring me in the face or something, but right now I'm blind to it. ]]>

d = 50 cm (diameter of circle)

L = 120 cm (length of cylinder)

h = 10 cm (height of circular segment)

The Figure to the left is sideview of the cylinder, and the figure to the right is front view.

first part is easy.

Find out how much liquid is in the cylinder

Code:

`A=r^2/2 * ((pi*v)/180 - sin(v))`

A=312,5*(1,854587-0,96)=279,5581 cm^2

V_(cylinder) = 279,5581 cm^2 * 120 cm = 33546,97 cm^3

V_(cylinder) = (33546,97 cm^3)/(1000 cm^3/L) = 33,54697 L

i need to find the new height of the circular segment, if i add 50 L liquid. so our new V_(cylinder) is 50 + 33,54697 = 83,54697 L.

how would i go about doing this? i can't exactly isolate V from the previous formula?