Use the C format specifier to output dollars and cents.
using System;
class Example {
public static void Main() {
decimal price;
decimal discount;
decimal discounted_price;
price = 19.95m;
discount = 0.15m;
discounted_price = price - ( price * discount);
Console.WriteLine("Discounted price: {0:C}", discounted_price);
}
}
Output Discounted price: $16.96
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
-
-
-
-
-
|