0
Halloween Candy
What am I missing? https://code.sololearn.com/cbth1WgHerEY/?ref=app
7 ответов
+ 1
Vincent Petrocelli
6 houses:
2 / 6 = 0.33
* 100 = 33.33
.33 < .5 -> Round rounds down to 33.00
Ceiling -> 34.00
+ 3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int houses;
houses = Convert.ToInt32(Console.ReadLine());
//your code goes here
int result = (int)(Math.Ceiling((double)2/houses*100));
Console.WriteLine(result);
}
}
}
0
You need to round up. You should use Math.Ceil() and then convert it to int.
0
Sorry the correct method name is Math.Ceiling()
Ceiling rounds always up.
0
Thx, but kinda curious, what input would make the code not round up?
- 1
I had to use Math.Round because Math.Ceil didnt exist
but same result unfortunatly