pleasega
pleasega

Reputation: 543

VB.net: How to have an unknown algebra for a equation

I am creating a calculator to cover the tax of an input. How do I have an unknown integer "m" as something like an algebra for my equation?

b = m - tm

"b" is money after tax. "m" is money before being taxed and "t" is Tax Rate in decimal

-

Example 1 - Money to cover tax [To find unknown variable 'm'] [t=0.06/6%]

100000000 = m - 0.06m ~ Plug-in all available numbers

100000000 = 0.94m ~ Subtraction

106382978 = m ~ Division

-

What is the code so that I can make m a unknown variable to be solved? VB.net Please help!

Upvotes: 0

Views: 288

Answers (2)

Mark Zucchini
Mark Zucchini

Reputation: 925

It based on previous solution and it's pretty dirty

Dim restCash = 4500
Dim taxRate = 0.1 ' e.x 10%
Dim initialCash = 0 ' That's what we looking for

If (taxRate = 1) Then ' It means that taxRate = 100%
    MsgBox("Tax rate cannot be 100%")
    Return
Else
    initialCash = restCash / (1 - taxRate)
End If

Upvotes: 2

NoChance
NoChance

Reputation: 5752

From what I understand, you want to solve for m. This means given a value for b and t, you want to find m.

Algebraically:

m = b/ (1-t)

The above equation is what you need to put in your program. Be aware that t=1 will cause an error, so make an 'IF' statement before you execute the equation.

Upvotes: 3

Related Questions