Calculating compound interest : Math Function « Development « VB.Net






Calculating compound interest

Calculating compound interest
 
Imports System

Public Class MainClass

    Shared Sub Main(ByVal args As String())

      Dim amount, principal As Decimal ' dollar amounts
      Dim rate As Double               ' interest rate
      Dim year As Integer              ' year counter
      Dim output As String             ' amount after each year

      principal = 1000
      rate = 0.05

      output = "Year" & vbTab & "Amount on deposit" & vbCrLf

      ' calculate amount after each year
      For year = 1 To 10
         amount = principal * (1 + rate) ^ year
         output &= year & vbTab & _
            String.Format("{0:C}", amount) & vbCrLf
      Next

      ' display output
      Console.WriteLine("Compound Interest" & output)

    End Sub
    

End Class

           
         
  








Related examples in the same category

1.Math: square root Math: square root
2.To the PowerTo the Power
3.Power ^ in VB.netPower ^ in VB.net
4.Math.Max DemoMath.Max Demo
5.Rnd DemoRnd Demo
6.Square Root in Math packageSquare Root in Math package
7.Round in MathRound in Math
8.Sign in MathSign in Math
9.Atan and TanAtan and Tan
10.Asin and SinAsin and Sin
11.Acos and CosAcos and Cos
12.Power in VBPower in VB
13.Math class: Square root, absolute value, Pi and PowerMath class: Square root, absolute value, Pi and Power
14.Math: Min, Max, Exp, Ceil, Round and Log10Math: Min, Max, Exp, Ceil, Round and Log10
15.Math.Abs Method returns the absolute value of a Decimal number.
16.Math.Atan returns the angle whose tangent is the specified number.
17.Math.BigMul produces the full product of two 32-bit numbers.
18.Math.Ceiling returns the smallest integral that is greater than or equal to the decimal number.
19.Math.Cos returns the cosine of the specified angle.
20.Math.Cosh returns the hyperbolic cosine of the specified angle.
21.Math.DivRem calculates the quotient and returns the remainder in an output parameter.
22.Math.DivRem calculates the quotient of two integers and returns the remainder in an output parameter.
23.Math.E Field represents the natural logarithmic base, specified by the constant, e.
24.Math.Exp returns e raised to the specified power.
25.Math.IEEERemainder returns the remainder resulting from the division
26.Math.Log returns the natural (base e) logarithm of a specified number.
27.Math.Log returns the logarithm of a specified number in a specified base.
28.Math.Log10 returns the base 10 logarithm of a specified number.
29.Math.Max returns the larger of two 8-bit unsigned integers.
30.Math.Min returns the smaller of two 8-bit unsigned integers.
31.Math.Pow returns a specified number raised to the specified power.
32.Math.Round rounds a decimal value to the nearest integral value.
33.Math.Round rounds a decimal value to a specified number of fractional digits.
34.Math.Round rounds a decimal to a specified number of fractional digits.
35.Math.Round (Double) rounds a double-precision floating-point value to the nearest integral value.
36.Rounds a double-precision floating-point value to a specified number of fractional digits.
37.Rounds a double-precision floating-point value to the specified number of fractional digits
38.Math.Sign returns a value indicating the sign of a decimal number.
39.Math.Tanh Returns the hyperbolic tangent of the specified angle.
40.Math.Truncate Calculates the integral part of a specified decimal number.