Use the decimal type to compute the future value of an investment : Decimal Calculation : Data Type C# Examples


C# Examples » Data Type » Decimal Calculation »

 

Use the decimal type to compute the future value of an investment









    
using  System;  
      
class  Example  {  
    public  static  void  Main()  {  
        decimal  amount;      
        decimal  rate_of_return;    
        int  years,  i;      
      
        amount  =  100000.0M;  
        rate_of_return  =  0.17M;  
        years  =  100;  
  
        Console.WriteLine("Original  investment:  $"  +  amount);  
        Console.WriteLine("Rate  of  return:  "  +  rate_of_return);  
        Console.WriteLine("Over  "  +  years  +  "  years");  
  
        for(i  =  0;  i  <  years;  i++)  {
            amount  =  amount  +  (amount  *  rate_of_return);  
        }
        Console.WriteLine("Future  value  is  $"  +  amount);    
    }  
}
    
   
  
   



Output

Original investment: $100000.0
Rate of return: 0.17
Over 100 years
Future value is $658546088583.68156535520269753


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Decimal Calculation