using System; class UseDecimal { public static void Main() { decimal price; decimal discount; decimal discounted_price; price = 19.95m; discount = 0.25m; // discount rate is 25% discounted_price = price - ( price * discount); Console.WriteLine("Discounted price: $" + discounted_price); } }
Discounted price: $14.9625
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 |