Formula needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Olsen

    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 ***
  • =?Utf-8?B?U3VydHVyWg==?=

    #2
    RE: Formula needed

    This isn't elegant, but it should work:

    Function InsuranceFee(By Val 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(dblT emp, 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 ***
    >

    Comment

    • =?Utf-8?B?U3VydHVyWg==?=

      #3
      RE: Formula needed

      Sorry, if you only add 60c each time, use this:

      Function InsuranceFee(By Val declaredValue As Double) As Double
      If declaredValue <= 100 Then Return 0
      Dim dblTemp As Double = 0
      dblTemp = 0.6 * CDbl(CLng(decla redValue) \ 100)
      If declaredValue Mod 100 0 Then
      dblTemp += 0.6
      End If
      If dblTemp < 1.8 Then dblTemp = 1.8
      dblTemp = Math.Round(dblT emp, 2) 'round to nearest cent
      Return dblTemp
      End Function

      Comment

      • Brian Gideon

        #4
        Re: Formula needed

        On Jul 7, 12:15 pm, Terry Olsen <tolse...@hotma il.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 Developersdexht tp://www.developersd ex.com***
        Public Function CalculateRate(B yVal value as Double) As Double
        If value 100 Then
        Return Math.Max(((valu e \ 100) + 1) * 0.60, 1.80)
        End If
        Return 0
        End Function

        Comment

        • Steve Gerrard

          #5
          Re: Formula needed

          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


          Comment

          • cfps.Christian

            #6
            Re: Formula needed

            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

            Comment

            • Terry Olsen

              #7
              Re: Formula needed

              Thanks everybody. I have some things to try now.

              "cfps.Christian " <ge0193387@otc. eduwrote in message
              news:ca840ca6-6e48-45fc-a131-63d11e6fdb68@k1 3g2000hse.googl egroups.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
              >

              Comment

              Working...