473,320 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Formula needed

I'm trying to calculate insurance fees for declared value rates. The
definition in the rate guide states this:

Declared Value Insurance Fee
<= $100.00 $0.00
$100 $0.60 for each $100 of the total value declared, with
a minimum charge of $1.80.

So here's the first few ranges:

0-100:0
100.01-300:1.80
300.01-400:2.40
400.01-500:3.00

I'm at a loss on creating a formula to figure this. Can anyone help?

*** Sent via Developersdex http://www.developersdex.com ***
Jul 7 '08 #1
6 859
This isn't elegant, but it should work:

Function InsuranceFee(ByVal declaredValue As Double) As Double
If declaredValue <= 100 Then Return 0
Dim dblTemp As Double = 0
dblTemp = 0.6 * declaredValue / 100
If dblTemp < 1.8 Then dblTemp = 1.8
dblTemp = Math.Round(dblTemp, 2) 'round to nearest cent
Return dblTemp
End Function

You might need to change the variable type from Double to Decimal or
whatever you are using.
--
David Streeter
Synchrotech Software
Sydney Australia
"Terry Olsen" wrote:
I'm trying to calculate insurance fees for declared value rates. The
definition in the rate guide states this:

Declared Value Insurance Fee
<= $100.00 $0.00
$100 $0.60 for each $100 of the total value declared, with
a minimum charge of $1.80.

So here's the first few ranges:

0-100:0
100.01-300:1.80
300.01-400:2.40
400.01-500:3.00

I'm at a loss on creating a formula to figure this. Can anyone help?

*** Sent via Developersdex http://www.developersdex.com ***
Jul 8 '08 #2
Sorry, if you only add 60c each time, use this:

Function InsuranceFee(ByVal declaredValue As Double) As Double
If declaredValue <= 100 Then Return 0
Dim dblTemp As Double = 0
dblTemp = 0.6 * CDbl(CLng(declaredValue) \ 100)
If declaredValue Mod 100 0 Then
dblTemp += 0.6
End If
If dblTemp < 1.8 Then dblTemp = 1.8
dblTemp = Math.Round(dblTemp, 2) 'round to nearest cent
Return dblTemp
End Function
Jul 8 '08 #3
On Jul 7, 12:15*pm, Terry Olsen <tolse...@hotmail.comwrote:
I'm trying to calculate insurance fees for declared value rates. The
definition in the rate guide states this:

Declared Value * * Insurance Fee
<= $100.00 * * * * * * $0.00*$100 * * * * * *$0.60 for each $100 of the total value declared, with

a minimum charge of $1.80.

So here's the first few ranges:

0-100:0
100.01-300:1.80
300.01-400:2.40
400.01-500:3.00

I'm at a loss on creating a formula to figure this. Can anyone help?

*** Sent via Developersdexhttp://www.developersdex.com***
Public Function CalculateRate(ByVal value as Double) As Double
If value 100 Then
Return Math.Max(((value \ 100) + 1) * 0.60, 1.80)
End If
Return 0
End Function
Jul 8 '08 #4
Terry Olsen wrote:
I'm trying to calculate insurance fees for declared value rates. The
definition in the rate guide states this:

Declared Value Insurance Fee
<= $100.00 $0.00
> $100 $0.60 for each $100 of the total value declared,
with a minimum charge of $1.80.

So here's the first few ranges:

0-100:0
100.01-300:1.80
300.01-400:2.40
400.01-500:3.00

I'm at a loss on creating a formula to figure this. Can anyone help?
One more. This one works for 599.99 and 600.00. :)

Public Function GetFee(ByVal Value As Double) As Double
Dim n As Integer
If Value <= 100 Then
n = 0
ElseIf Value <= 300 Then
n = 3
Else
n = CInt(Fix(Value / 100))
If Value Mod 100 0 Then
n += 1
End If
End If
Return Math.Round(n * 0.6, 2)
End Function
Jul 8 '08 #5
In my tests I found that the rounding is going to be the most complex.

Dim DeclaredValue as Double = [...]
Dim InsuranceFee as Double = 0

If DeclaredValue 100 AND DeclaredValue < 300.01 Then
InsuranceFee = 1.80
Else If DeclaredValue 300
Dim Multiplier as Integer = Convert.ToInt32(DeclaredValue / 100)
If DeclaredValue Multiplier * 100 Then
Multiplier += 1
End If
InsuranceFee = .6 * Multiplier
End If

Jul 8 '08 #6
Thanks everybody. I have some things to try now.

"cfps.Christian" <ge*******@otc.eduwrote in message
news:ca**********************************@k13g2000 hse.googlegroups.com...
In my tests I found that the rounding is going to be the most complex.

Dim DeclaredValue as Double = [...]
Dim InsuranceFee as Double = 0

If DeclaredValue 100 AND DeclaredValue < 300.01 Then
InsuranceFee = 1.80
Else If DeclaredValue 300
Dim Multiplier as Integer = Convert.ToInt32(DeclaredValue / 100)
If DeclaredValue Multiplier * 100 Then
Multiplier += 1
End If
InsuranceFee = .6 * Multiplier
End If
Jul 9 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Phoon Chee Keong | last post by:
Is that a formula in vb.net like Ms Excel? Currently my Excel formula is "=(((ROUNDUP(I30/3000,0)+1)*G30)/1000)+((ROUNDUP(G30/10000,0))*I30/1000)", but in vb.net how to write. Any idea? ...
7
by: Helen | last post by:
vb .net 200 crystal reports Oracl Acces Hi, I have all selection formula results needed from the main crystal report, called in the vb form (Oracle db) I now need to build in the logic in...
0
by: RJN | last post by:
Hi I have a main report and a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be evaluated after the formula in the main...
0
by: RJN | last post by:
Hi Sorry for posting this message again. I have a main report and a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be...
4
by: adrian | last post by:
hello! i am using visual studio 2000 and am trying to insert a formúla into an excel cell. the code goes like this: with excel .workbooks.open (datei(i)) .activesheet.name ="statistik 2004"...
0
by: rjn | last post by:
Hi I have a main report in which I have inserted a sub report. I have a formula field on the main report and one on the sub report. I want the formula in the subreport to be evaluated after the...
4
by: DellaCroce | last post by:
Does anyone here have the formula for calculating distance give two pairs of Longitude/Latitude coordinates? Please share this with me if you would. -- Greg
8
by: GB | last post by:
Hello, How to calculate value for the following formula (I need C# code): res = (((m+1)(m+2)...(m+(k-1)))/1.2...(k-1)) or more generalized formula is: k-1 __ | | (m+i)
7
by: Bobh | last post by:
I am trying to figure out some code for a report issue; I have an employee who has a incentive scheme. I have a report showing various income amounts and in the report footer I vae totals for...
1
by: afaircloth | last post by:
I am attempting to build an inventory program for personal use and training. I would like to add a formula to a query that is pulling my table data with which I will populate a form. I need to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.