Use the decimal type to compute the future value of an investment : decimal Calculation « Data Type « C# / CSharp Tutorial






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);  
  } 
}
Original investment: $100000.0
Rate of return: 0.17
Over 100 years
Future value is $658546088583.68156535520269753








2.31.decimal Calculation
2.31.1.Use the decimal type to compute a discount.
2.31.2.Use the decimal type to compute the future value of an investment