adddesign

By Think Positive, Get Positive on 11:00:00 AM

Filed Under: , ,

DECIMAL TYPE

Decimal is the data type utilizes 128 bits which represents within the range 1E-28 to 7.9E+28. It can accurately represents upto 28 decimal places.

Program using Decimal type to compute a discount

using system;

Class discounts

{
public static void Main()
{
decimal price;
decimal discount;
decimal disprice;

price = 16.0;
discount = 0.10
disprice = price - (price*discount);

Console.WriteLine("The Discounted Price : $"+ disprice);
}
}

output:

The Discounted Price:$ 14.4

------------------------------------------------------------------------------------------------

Program using Decimal to compute a future value

using system;

class futurevalue

{
public static void Main()

{

decimal amount;
decimal rateofreturn;
int i, years;
amount = 1000.0;
rateofreturn = 0.07;
years = 10;

Console.WriteLine( "Original Investment:$"+amount);
Console.WriteLine("Rate of Retun:$"+ rateofreturn);
Console.WriteLine("Over"+Years+"Years");

for(i=0;i<=years;i++) { amount = amount+(amount*rateofreturn); Console.WriteLine("The Future Value:$"+amount); } } } Output:

Original Investment : $1000
Rate of return : $0.07
Over 10 Years

The Future Value : $ 1967.15135728956532249000

-----------------------------------------------------------------------------------------------

goto BOOL

0 comments for this post