+ 2
In the c# project section Halloween Candy
Has anyone else entered there code and had the remain tests not unlock ?? My code works and cracks the first 2 tests?? Any ideas??
4 Answers
+ 3
Maybe you have an issue with rounding.
Post your code attempt here, then people can review.
+ 3
The task says to "round up". Use Math.Ceiling instead of Math.Round
+ 2
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());
double probability = 2.0 /(houses);
int percentage = (int)Math.Round(probability * 100);
Console.WriteLine(percentage);
}
}
}
+ 1
Nice, thank you