Arama butonu
Bu konudaki kullanıcılar: 1 misafir
4
Cevap
1757
Tıklama
0
Öne Çıkarma
C# ta harf olarak girilen not ile ortalama hesaplama // Yardım
K
12 yıl
Er
Konu Sahibi

Arkadaşlar merhaba,

c# bir projem var ancak bir yerde takıldım. Yardımcı olabilir misiniz acaba..


using System; 
using System.Collections.Generic;

{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void tabPage1_Click(object sender, EventArgs e)
{

}

private void Form1_Load(object sender, EventArgs e)
{
string[] Donem_1 = { "Matematik", "Fizik", "İngilizce", "Programlama" };
string[] Donem_2 = { "Türk Dili", "Kimya", "Veri Tabanı", "İnternet Programcılığı" };
string[] Kod_1 = { "MAT101", "FIZ101", "DIL101", "PRG101" };
string[] Kod_2 = { "TUR102", "KIM102", "VTB102", "INP102" };
byte[] AKTS_1 = { 3, 3, 2, 4 };
byte[] AKTS_2 = { 2, 2, 4, 5 };


textBox7.Text = Donem_1[0];
textBox8.Text = Donem_1[1];
textBox9.Text = Donem_1[2];
textBox10.Text = Donem_1[3];

textBox39.Text = Donem_2[0];
textBox38.Text = Donem_2[1];
textBox37.Text = Donem_2[2];
textBox36.Text = Donem_2[3];

textBox3.Text = Kod_1[0];
textBox4.Text = Kod_1[1];
textBox5.Text = Kod_1[2];
textBox6.Text = Kod_1[3];

textBox43.Text = Kod_2[0];
textBox42.Text = Kod_2[1];
textBox41.Text = Kod_2[2];
textBox40.Text = Kod_2[3];


textBox11.Text = AKTS_1[0].ToString();
textBox12.Text = AKTS_1[1].ToString();
textBox13.Text = AKTS_1[2].ToString();
textBox14.Text = AKTS_1[3].ToString();


textBox35.Text = AKTS_2[0].ToString();
textBox34.Text = AKTS_2[1].ToString();
textBox33.Text = AKTS_2[2].ToString();
textBox32.Text = AKTS_2[3].ToString();



}

private float Katsayi(string Notu)
{
if (Notu == "AA")
{
return 4;
}
else if (Notu == "BA")
{
return 3.5f;
}
else if (Notu == "BB")
{
return 3;
}
else if (Notu == "CB")
{
return 2.5f;
}
else if (Notu == "CC")
{
return 2;
}
else if (Notu == "DC")
{
return 1.5f;
}
else if (Notu == "DD")
{
return 1;
}
else
return 0;
}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}

private void label3_Click(object sender, EventArgs e)
{

}

private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{

}

private void label7_Click(object sender, EventArgs e)
{

}

private void label7_Click_1(object sender, EventArgs e)
{

}

private void textBox7_TextChanged(object sender, EventArgs e)
{



}

private void textBox15_TextChanged(object sender, EventArgs e)
{

}

private void textBox19_TextChanged(object sender, EventArgs e)
{


}

private void button1_Click(object sender, EventArgs e)
{



int toplam = Convert.ToInt32(textBox11.Text) + Convert.ToInt32(textBox12.Text) + Convert.ToInt32(textBox13.Text) + Convert.ToInt32(textBox14.Text);
textBox19.Text = toplam.ToString();


}

private void button2_Click(object sender, EventArgs e)
{

if (textBox25.Text == string.Empty)
{
MessageBox.Show("Öncelikle 1. ve 2. yarıyıl ortalamalarını hesaplayınız. ", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);


return;
}


else if (textBox26.Text == string.Empty)
{
MessageBox.Show("Öncelikle 1. ve 2. yarıyıl ortalamalarını hesaplayınız. ", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Warning);


return;
}

int toplam2 = Convert.ToInt32(textBox32.Text) + Convert.ToInt32(textBox33.Text) + Convert.ToInt32(textBox34.Text) + Convert.ToInt32(textBox35.Text);
textBox20.Text = toplam2.ToString();

}

private void button3_Click(object sender, EventArgs e)
{

int toplam3 = Convert.ToInt32(textBox32.Text) + Convert.ToInt32(textBox33.Text) + Convert.ToInt32(textBox34.Text) + Convert.ToInt32(textBox35.Text) + Convert.ToInt32(textBox11.Text) + Convert.ToInt32(textBox12.Text) + Convert.ToInt32(textBox13.Text) + Convert.ToInt32(textBox14.Text);
textBox21.Text = toplam3.ToString();

}

private void textBox21_TextChanged(object sender, EventArgs e)
{

}
}
}



Benim burada yapmak istediğim Textbox a harf bazında girilen sayıyı rakama dönüştürüp başka bir textboxtaki değer ile çarpmak.

Mesela AA diye giriş yapan birinin notu 4 e çevrilip başka bir textbox ile çarpılacak.

Ama notlar harf olarak girildiği için sanırım convert işlemini yapamıyorum.

Yardımcı olabilirseniz çok sevinirim.

Şimdiden teşekkürler.





< Bu mesaj bu kişi tarafından değiştirildi kristal90 -- 13 Temmuz 2013; 11:09:07 >

_
12 yıl
Çavuş

öncelikle harf notları belli olduğu için (aa,bb,cc) gibi textbox yerine combobox kullan, items özelliğinde collection basıp her harf notunu ekle. AA BB CC gibi. alt satıra geçerek yaz ama.

sonra buttonuna şöyle bir kod koyabilirsin.

switch (comboBox1.SelectedText)
{
case "AA": label1.Text="4";// yada carpan=4;
break;
case "BB": label1.Text="3";// yada carpan=3;
break;
case "CC": label1.Text="2";// yada carpan=2;
break;
}


yada combobox a value değeri ekleme diye arat daha kolay olur
combobox1.selectedvalue diyerek direk elde edebilirsin çarpan değerini gibi gibi


Bu mesaja 1 cevap geldi.
B
9 yıl
Teğmen

konuyu hortlatmış oluyorum ama benimde böyle bir sorunum var yeni konu açmak istemedim. Arkadaş yardımcı olmaya çalışmış ya ben yapamadım yada eksiklik var. Bu konuda yardım lazım. Bende harfleri girerek ortalama almaya çalışıyorum kodlarım arkadaşın verdiği şekilde ama butona bastığımda hiçbir işlem yapmıyor. Hatada almıyorum bu konuda yeniyim bu tarz örneklerle kendimi geliştirmeye çalışıyorum bu konuda takıldım birazda inatçıyım bunu çözmeden başka örneklere geçmek istemiyorum işten anlayan varsa beynimi yakan şu sorundan kurtarsın beni

switch (comboBox1.SelectedText)
{
case "AA":
label6.Text = "4";
break;

case "BA":
label6.Text = "3.5";
break;

case "BB":
label6.Text = "3";
break;
}


Bu mesaja 1 cevap geldi.
G
9 yıl
Yarbay

switch (comboBox1.SelectedItem.ToString()) {
case "AA":
label1.Text = "4";
break;
case "BA":
label1.Text = "3.5";
break;
case "BB":
label1.Text = "3";
break;
}


Bu mesaja 1 cevap geldi.
B
9 yıl
Teğmen

quote:

Orijinalden alıntı: Gökşen PASLI

switch (comboBox1.SelectedItem.ToString()) {
case "AA":
label1.Text = "4";
break;
case "BA":
label1.Text = "3.5";
break;
case "BB":
label1.Text = "3";
break;
}

Teşekkür ederim metin ve sayısal değerlerin çevrilme mantığını biraz daha kavramam gerekiyor sanırım



DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.