Need help with a Calculation

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: Need help with a Calculation

#### Hybrid View

1. Registered User
Join Date
Jan 2006
Posts
10

## Need help with a Calculation

Well im making a calculator but i want to put this into my calculator
1=0.25
2or3=0.50
4or5=0.75
6or7=1.00
8or9=1.25
10o11=1.50
12or13=1.75
14or15=2.00
16or17=2.25
18or19=2.50
20or21=2.75
22or23=3.00
24or25=3.25
26or27=3.50

and all the way up to
98or99=12.25

Hope you understand and would like this code alot to finish my calculator

2. Registered User
Join Date
Dec 2005
Location
New Jersey
Posts
290
Not sure i understand... so you want when you input 26 or 27 to get 3.5?

Here's some pseudocode:
Code:
```if number is odd
result = number - 1
end if
result = (result / 2.0 * .25) + .25;```

3. Registered User
Join Date
Jan 2006
Posts
10
ill try this and reply i

4. Registered User
Join Date
Jan 2006
Posts
10
this is what i got
Code:
```Option Explicit

Private Sub Command1_click()
Dim firstNumber As Integer
Dim secondNumber As Integer
Dim thirdNumber As Integer
Dim forthNumber As Integer
Dim fithNumber As Integer
Dim Result As Integer
firstNumber = Attack.Text * 0.325
secondNumber = Strenght.Text * 0.325
thirdNumber = Deffence.Text / 4
forthNumber = Hits.Text / 4
fithNumber = Prayer.Text * 0.25
Result = firstNumber + secondNumber + thirdNumber + forthNumber + fithNumber
Text1.Text = Result
End Sub```
and what i want is instead of prayer.text *0.25 i want it to go up and extra 0.25 every even number and still be same for lower odd number than it

5. Registered User
Join Date
Jan 2006
Posts
10
i think you answer would work but i dont know where to put it into my code could you posibly put it in for me, thanks for helping

6. Registered User
Join Date
Dec 2005
Location
New Jersey
Posts
290
I probably would help you there, but I really only know Java and C/C++

7. Senior Member
Join Date
Nov 2003
Location
Portland, OR
Posts
8,387
Try this:

fifthNumber = ((Prayer.Text \ 2) + 1) * 0.25

8. Registered User
Join Date
Jan 2006
Posts
10
its alittle off,

Is thier a calculation i can use so that prayer.text would multiply only on even numbers and stay same as previous even number when it is odd? i realy need this its a vital calculation

9. Registered User
Join Date
Jan 2006
Posts
10
what i want is,

if Prayer.text = odd then - 1 then *0.25
If Prayer.text = Even *0.25

I want a code that would do that i know what i typed probly isnt even code but it says what i want

10. Registered User
Join Date
Jan 2006
Posts
10
ive fixed this problem but now i got anoughter
VB seems to be rounding up or down my numbers is thier neway of stoping this?

11. Senior Member
Join Date
Nov 2003
Location
Portland, OR
Posts
8,387

12. Registered User
Join Date
Jan 2006
Posts
10
i worked it out i had
Code:
`As FirstNumber interget`
But i changed that and now it works thank you for all your help

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise