0

How to Solve Halloween candy in c #

I cannot complete the puzzle. My first answer it shows 66 but answer comes 7

29th Jan 2020, 4:29 PM
Coder
10 Respuestas
+ 3
Please show us your code so we can address the problem or problems you are having. Thanks
29th Jan 2020, 4:41 PM
BroFar
BroFar - avatar
0
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.ToInt16(Console.ReadLine()); double percent; percent = (200/ houses ); Console.WriteLine(percent ); } } }
29th Jan 2020, 4:57 PM
Coder
0
Th code
29th Jan 2020, 4:58 PM
Coder
0
you're missing a step from the task. Output Format A percentage value rounded up to the nearest whole number.
29th Jan 2020, 5:01 PM
Taste
Taste - avatar
0
How to do that? I am a newbie in coding and unable to do that pls help me
29th Jan 2020, 5:07 PM
Coder
0
change percentage to datatype that can hold a decimal value. then round it up. https://docs.microsoft.com/en-us/dotnet/api/system.math.ceiling?view=netframework-4.8
29th Jan 2020, 5:18 PM
Taste
Taste - avatar
0
How to do I tried math.ceiling it didn't work
29th Jan 2020, 5:21 PM
Coder
0
In the question Halloween candies say that there would be only 2 dollar bills. So we have to do 2 divided by houses multiplied by 100
29th Jan 2020, 5:31 PM
Coder
0
Try math ceiling - 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()); Console .WriteLine(Math.Ceiling(200.0/houses) ); } } }
7th Feb 2020, 7:26 AM
Saurabh Pandey
Saurabh Pandey - avatar
- 1
you can work on the calculation percentage for example, using your current formula 2% of 50 200/50 => 4 which is wrong, 2% of 50 should be 1. 50*2/100 => 1
29th Jan 2020, 5:28 PM
Taste
Taste - avatar