Mega Code Archive

 
Categories / C# / Data Types
 

Use the decimal type to compute a discount

/* C#: The Complete Reference  by Herbert Schildt  Publisher: Osborne/McGraw-Hill (March 8, 2002) ISBN: 0072134852 */ // Use the decimal type to compute a discount.     using System;      public class UseDecimal {        public static void Main() {          decimal price;       decimal discount;      decimal discounted_price;          // compute discounted price      price = 19.95m;       discount = 0.15m; // discount rate is 15%        discounted_price = price - ( price * discount);          Console.WriteLine("Discounted price: $" + discounted_price);     }      }