Şu kodları consola çevirebilir misiniz? Konsol bilgim yok. Program şöyle çalışıyor: 100 Tane 14 veya 15 sayısını oluşturuyor random sayesinde. Ve kaç tane 14, kaç tane 15 olduğunu ekrana yazdırıyor.
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _14_15_Yaş
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random r = new Random();
int sayi, i;
int countonbes = 0;
int countondort = 0;
listBox1.Items.Clear();
for (i = 0; i < 100; i++)
{
sayi = r.Next(14, 16);
listBox1.Items.Add(sayi);
if (sayi.ToString() == "15")
countonbes = countonbes + 1;
else if (sayi.ToString() == "14")
countondort = countondort + 1;
label4.Text = countonbes.ToString() ; //kaç tane onbeş olduğunu label1 e yazdır.
label3.Text = countondort.ToString() ; //kaç tane ondört olduğunu label2 ye yazdır
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}