+ 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??

16th Apr 2023, 9:45 AM
Sam Castleton
Sam Castleton - avatar
4 Antworten
+ 3
Maybe you have an issue with rounding. Post your code attempt here, then people can review.
16th Apr 2023, 10:04 AM
Tibor Santa
Tibor Santa - avatar
+ 3
The task says to "round up". Use Math.Ceiling instead of Math.Round
16th Apr 2023, 10:15 AM
Tibor Santa
Tibor Santa - avatar
+ 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); } } }
16th Apr 2023, 10:12 AM
Sam Castleton
Sam Castleton - avatar
+ 1
Nice, thank you
16th Apr 2023, 10:16 AM
Sam Castleton
Sam Castleton - avatar