Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

C# calculate drop rate of sandwhiches

I have a school assignment that I would like to get done, however, I have issues trying to reach my teacher during the holidays.

I'm supposed to check if I drop 100 sandwiches how many of them will fall the right way up?

I have a slider where I can change my % value, but I'm not sure how I would do the calculation. Id assume I would do this in a for loop I have a slider where I get the Fortune value called: FortuneValue

[Image: Yjh0k.png]


PHP Code

<?php 
int rightWay 
= 0;
int wrongWay = 0;
int tries = Convert.ToInt32(Tries.Text);


for (
int i = 0; i < tries; i++)
{
} 
Is the slider how much chance it will be the right way up?
Code
rightWay = ammountdropped * (percentChanceOfBeingRightWayUp / 100)

and the wrong way is the rest. Basic math yo.
Lotta blood to let, peace to make, give a fuk about a check
(Dec 24, 2018 04:34 AM)BahNahNah Wrote:  Is the slider how much chance it will be the right way up?
Code
rightWay = ammountdropped * (percentChanceOfBeingRightWayUp / 100)

and the wrong way is the rest. Basic math yo.

Thats what I did before the holidays, how ever I failed. I was told "Note that probability is not the same as actual outcome".
Meaning if I drop 100 sandwhiches and I have only have a 50% chance not everyone will land the right way up

Because I did this
Code
int tries = Convert.ToInt32(Tries.Text);

            //Mackor åt rätt håll
            int rightWay = (int) (tries * (FortuneValue.Value / 100));
            //Mackor åt fel håll
            int wrongWay = FindDifference(rightWay, tries);
(Dec 24, 2018 04:41 AM)Carlsson94 Wrote:  Thats what I did before the holidays, how ever I failed. I was told "Note that probability is not the same as actual outcome".
Meaning if I drop 100 sandwhiches and I have only have a 50% chance not everyone will land the right way up

Because I did this
Code
           int tries = Convert.ToInt32(Tries.Text);

           //Mackor åt rätt håll
           int rightWay = (int) (tries * (FortuneValue.Value / 100));
           //Mackor åt fel håll
           int wrongWay = FindDifference(rightWay, tries);

For each attempt, check the probability that it is the right way up. For example, 50/50
Code
for(i = 0; i < numberofflips; i++){
    if(rnd.Next(0, 2) == 0){
        rightway++;
    }else{
        wrongway++;
    }
}
Lotta blood to let, peace to make, give a fuk about a check
(Dec 24, 2018 05:41 AM)BahNahNah Wrote:  For each attempt, check the probability that it is the right way up. For example, 50/50
Code
for(i = 0; i < numberofflips; i++){
   if(rnd.Next(0, 2) == 0){
       rightway++;
   }else{
       wrongway++;
   }
}

Now I just have too implement my Fortune slider, but I think I'm on the right path, cheers!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by littleblueguy24Jun 14, 2022 12:03 AM 2 122 Jun 14, 2022 12:03 AM
Last Post: littleblueguy24
[C#] by sdhp442May 6, 2019 04:17 AM 2 156 May 6, 2019 04:17 AM
Last Post: sdhp442
[C#] by -PUBG-Sep 24, 2018 09:04 PM 11 391 Sep 24, 2018 09:04 PM
Last Post: 0xDEAD10CC