CSharp examples for Language Basics:decimal
Read decimal from console window
using System;/* w w w . j a va 2 s .co m*/ class Account { public static void Main() { const decimal InterestRatePaid = 0.1m; const decimal InterestRateCharged = 0.15m; decimal balance; Console.Write("Please enter account balance: "); balance = Convert.ToDecimal(Console.ReadLine()); if(balance >= 0) { Console.WriteLine("Interest paid: {0,13:C}", (balance * InterestRatePaid)); balance = balance + (balance * InterestRatePaid); } else { Console.WriteLine("Interest charged: {0,10:C}", -(balance * InterestRateCharged)); balance = balance + (balance * InterestRateCharged); } Console.WriteLine("New balance: {0,15:C}", balance); } }