2 sayı ile 4 işlem

1

int sayı1, sayı2;
sayı1 = int.Parse(t1.Text);
sayı2 = int.Parse(t2.Text);
t3.Text = (sayı1 + sayı2).ToString();
}
private void b2_Click(object sender, EventArgs e)
{
int sayı1, sayı2;
sayı1 = int.Parse(t1.Text);
sayı2 = int.Parse(t2.Text);
t3.Text = (sayı1 – sayı2).ToString();
}

private void b3_Click(object sender, EventArgs e)
{
int sayı1, sayı2;
sayı1 = int.Parse(t1.Text);
sayı2 = int.Parse(t2.Text);
t3.Text = (sayı1 * sayı2).ToString();
}
private void b4_Click(object sender, EventArgs e)
{
int sayı1, sayı2;
sayı1 = int.Parse(t1.Text);
sayı2 = int.Parse(t2.Text);
t3.Text = (sayı1 / sayı2).ToString();

C# BARBUT OYUNU YAPIMI

Merhaba,
Aşağıda Barbut oyununu yapıyoruz.
Başla butonuna bastığımız rastgele sayılar üretilecek ve yüksek sayı gelen oyuncunun kazandığı listbox ta yazacak.
Barbut

Random rnd = new Random();
int oyuncu1;
int oyuncu2;
oyuncu1 = rnd.Next(1, 13);
oyuncu2 = rnd.Next(1, 13);
T1.Text = oyuncu1.ToString();
T2.Text = oyuncu2.ToString();
if (oyuncu1>oyuncu2)
{
listBox1.Items.Add(“1. oyuncu kazandı.”);
}
else if(oyuncu2>oyuncu1)
{
listBox1.Items.Add(“2.Oyuncu kazandı.”);
}
else if (oyuncu1 == oyuncu2)
{
listBox1.Items.Add(“Berabere”);
}

C# Kullanıcı giriş kontrolü (WFA)

s1 s2

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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void t1_TextChanged(object sender, EventArgs e)
{

}
private void button1_Click(object sender, EventArgs e)
{
if (t1.Text == “mehmet” & t2.Text == “123456”)
{
MessageBox.Show(“Hoş geldiniz.”);

//Aşağıda eklediğim alan ile sayfaya giriş yaptıktan sonra farklı bir form sayfasını çağırabiliriz, örneğin bir alttaki örnekteki not hesaplama formunu çağıralım.

//Form2 fo = new Form2();
//fo.Show();

}
else
{
MessageBox.Show(“Hatalı giriş”);
}

form

C# Not hesaplama uygulaması (WFA)

Merhaba,
Senaryo;
3 sınavlı sistemde girilen 3 adet sınav sonucunu ekle ve ekrana yazdır.
Koşullar;

Girilen değerler 0’dan küçük 100’den büyük olamaz. Boş textbox bırakılmaz. Textbox lara sitring değer giremez.

10 11Adsız 13Adsız 14Adsız

int n1, n2, n3;
int sonuc = 0;

if ((textBox1.Text== “”) || (textBox2.Text==””) || (textBox3.Text==””))
{
MessageBox.Show(“Boş veri girişi yaptınız!”);
}
n1 = int.Parse(textBox1.Text);
n2 = int.Parse(textBox2.Text);
n3 = int.Parse(textBox3.Text);
sonuc = (n1 + n2 + n3) / 3;
if (n1 >= 100 || n1 < 0 || n2 >= 100 || n2 < 0 || n3 >= 100 || n3 < 0)
{
MessageBox.Show(“Girilen not 100’den büyük ve 0’dan küçük olamaz”);
}
else if (sonuc >= 70)
{
MessageBox.Show(“Geçtiniz, notunuz ” + sonuc.ToString());
}
else
{
MessageBox.Show(“Kaldınız, notunuz ” + sonuc.ToString());
}

Klavyeden girilen sayıların tek ve çift sayı özelinde toplamı

int s;
int t = 0;    // t = tek sayıları temsil eder.
int c = 0;    // c = çift sayıları temsil eder.
for (int i = 1; i <= 4; i++)
{
Console.WriteLine(“Sayı giriniz.”);
s = Convert.ToInt32(Console.ReadLine());
if (s % 2 == 0)
{
c = c + s;
}
else
{
t = t + s;
}
}
Console.WriteLine(c + ” = Girilen çift sayıların toplamı”);
Console.WriteLine(t + ” = Girilen tek sayıların toplamı”);
Console.WriteLine(“Çift sayı ve tek sayıların toplamı” + c + t);
Console.ReadLine();

C# doğum yılı ,yaş hesaplama ve doğum yılından emeklilik hesaplama

int yas;
int yil;
Console.WriteLine(“Yaşınızı giriniz.”);
yas = Convert.ToInt32(Console.ReadLine());
yil = DateTime.Now.Year – yas;
Console.WriteLine(yil + ” Doğumlusunuz.”);
Console.ReadLine();
Console.WriteLine(“Doğum yılınız nedir.”);
yas = Convert.ToInt32(Console.ReadLine());
yil = DateTime.Now.Year – yas;
Console.WriteLine(yil + ” yaşındasınız.”);
if (yil < 65)
{
Console.WriteLine(“Emekli olamazsınız.”);
}
else
{
Console.WriteLine(“Emekli olabilirsiniz.”);
}
Console.ReadLine();