Use the decimal type to compute a discount.
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);
}
}
Output Discounted price: $14.9625
|
HTML code for linking to this page:
Related in same category :
-
|