Hi All,
int heightGroupBox = (((numberFloor / 3) * 25) + 30);
my code, but numerFloor is an integer and I have problems with ceiling the result,
for example I need 7/3 = 3 or 11/3 = 4 etc.
any suggestions? thanx
Hi All,
int heightGroupBox = (((numberFloor / 3) * 25) + 30);
my code, but numerFloor is an integer and I have problems with ceiling the result,
for example I need 7/3 = 3 or 11/3 = 4 etc.
any suggestions? thanx
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question.
Sanjeeb LenkaPosted Sep 15, 2013, 3:02 PM
try this:
sample:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Class2
{
static void Main(string[] args)
{
Console.WriteLine("Enter a number");
int numberFloor = Convert.ToInt32(Console.ReadLine());
decimal a = (decimal)numberFloor / 3;
decimal res = Math.Round(a);
int heightGroupBox = ((Convert.ToInt32(res)* 25) + 30);
Console.WriteLine(heightGroupBox);
Console.ReadKey();
}
}
}
if you want to write it in a single line try this:
int heightGroupBox = ((Convert.ToInt32(Math.Round((decimal)numberFloor / 3)) * 25) + 30);
VulpesPosted Sep 16, 2013, 7:29 AM