Round up a number
using System;
using System.Data;
using System.Text.RegularExpressions;
class Class1{
static void Main(string[] args){
Console.WriteLine(RoundUp(.4));
Console.WriteLine(RoundUp(.5));
Console.WriteLine(RoundUp(.6));
Console.WriteLine(RoundUp(1.4));
Console.WriteLine(RoundUp(1.5));
Console.WriteLine(RoundUp(1.6));
Console.WriteLine(RoundUp(2.4));
Console.WriteLine(RoundUp(2.5));
Console.WriteLine(RoundUp(2.6));
Console.WriteLine(RoundUp(3.4));
Console.WriteLine(RoundUp(3.5));
Console.WriteLine(RoundUp(3.6));
}
public static double RoundUp(double valueToRound)
{
return (Math.Floor(valueToRound + 0.5));
}
}
|
HTML code for linking to this page:
Related in same category :
-
|