using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace DoorsGame { public partial class Form1 : Form { private int no_switch = 0; private int did_switch = 0; private int total_trials = 0; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { total_trials++; Random r = new Random(); int door_chosen = r.Next(0, 3); int correct_door = r.Next(0, 3); if (correct_door == door_chosen) { no_switch++; listBox1.Items.Add("Win"); listBox2.Items.Add("Loss"); } else { did_switch++; listBox1.Items.Add("Loss"); listBox2.Items.Add("Win"); } lpDNS.Text = ((int)((no_switch * 100) / total_trials)).ToString() + "%"; lpDS.Text = ((int)((did_switch * 100) / total_trials)).ToString() + "%"; } private void button2_Click(object sender, EventArgs e) { for (int i = 0; i < 1000; i++) button1_Click(sender, e); } } }