I am writing a program where I put different students in different classrooms. I'm having some trouble figuring out how to use probabilities in C#, and programming in general. I want it to be a 5% probability to become a student in Alpha, 10& for Omega & 60% for Nightwalkers. I don't understand what numbers to put in.My method right now:
public string AssignClassroom() { int rand = random.Next(0, 100); { if (rand < 5) // or >95%? { student.Classroom = "Alpha"; } if (rand < 10) // or >90? { student.Classroom = "Omega"; } if (rand < 60) // or >40? { student.Classroom = "Nightwalkers"; } } }
elsebetween statements.