0
How to Solve Halloween candy in c #
I cannot complete the puzzle. My first answer it shows 66 but answer comes 7
10 Respuestas
+ 3
Please show us your code so we can address the problem or problems you are having.
Thanks
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 );
}
}
}
0
Th code
0
you're missing a step from the task.
Output Format
A percentage value rounded up to the nearest whole number.
0
How to do that? I am a newbie in coding and unable to do that pls help me
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
0
How to do I tried math.ceiling it didn't work
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
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) );
}
}
}
- 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