parse decimal : Parse « Data Types « C# / C Sharp






parse decimal

  
using System;

public class Class1 {
    public static void Main(string[] args) {
        Console.Write("Enter principal:");
        string sPrincipal = Console.ReadLine();
        decimal mPrincipal = decimal.Parse(sPrincipal);

        Console.Write("Enter interest:");
        string sInterest = Console.ReadLine();
        decimal mInterest = decimal.Parse(sInterest);

        decimal mInterestPaid;
        mInterestPaid = mPrincipal * (mInterest / 100);

        decimal mTotal = mPrincipal + mInterestPaid;

        Console.WriteLine("Principal     = " + mPrincipal);
        Console.WriteLine("Interest      = " + mInterest + "%");
        Console.WriteLine("Interest paid = " + mInterestPaid);
        Console.WriteLine("Total         = " + mTotal);
    }
}

   
  








Related examples in the same category

1.char.Parse
2.int.Parse
3.double.Parse
4.bool.Parse
5.Determines whether the supplied number is an integer.
6.Determines whether the supplied number is a decimal number.
7.Determines whether the supplied number is of numeric type.
8.Is Valid Integer