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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 15, 2013, 11:02 AM EDT
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);
VulpesRank #55 · 29.2K reputationPosted Sep 16, 2013, 3:29 AM EDT