|
|
|
Bilimsel hesap makinesii(c#) sin,cos,tan,arcsin,arccos,arctan,log,üs,e^..using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace calculator
{
public partial class Form1 : Form
{
double işlem = 0;
double sayi1;
double sayi2 ;
int seçilen;
double tanjı;
double açı;
double acıradyan;
// double acıdeger;
//double ac=0;
public Form1()
{
InitializeComponent();
}
// aşağıdaki kodda switch -case yapısı kullanmıştım hata verdi.. lütfen siz kullanın..
private **** button1_Click(object sender, EventArgs e)
{
if (((Button)sender).Name == "button1")
{
if (textBox1.Text == "")
textBox1.Text = "1";
else
textBox1.Text = textBox1.Text + "1";
}
else
if (((Button)sender).Name == "button2")
{
if (textBox1.Text == "")
textBox1.Text = "2";
else
textBox1.Text = textBox1.Text + "2";
}
else
if (((Button)sender).Name == "button3")
{
if (textBox1.Text == "")
textBox1.Text = "3";
else
textBox1.Text = textBox1.Text + "3";
}
else
if (((Button)sender).Name == "button4")
{
if (textBox1.Text == "")
textBox1.Text = "4";
else
textBox1.Text = textBox1.Text + "4";
}
else
if (((Button)sender).Name == "button5")
{
if (textBox1.Text == "")
textBox1.Text = "5";
else
textBox1.Text = textBox1.Text + "5";
}
else
if (((Button)sender).Name == "button6")
{
if (textBox1.Text == "")
textBox1.Text = "6";
else
textBox1.Text = textBox1.Text + "6";
}
else
if (((Button)sender).Name == "button7")
{
if (textBox1.Text == "")
textBox1.Text = "7";
else
textBox1.Text = textBox1.Text + "7";
}
else if (((Button)sender).Name == "button8")
{
if (textBox1.Text == "")
textBox1.Text = "8";
else
textBox1.Text = textBox1.Text + "8";
}
else
if (((Button)sender).Name == "button9")
{
if (textBox1.Text == "")
textBox1.Text = "9";
else
textBox1.Text = textBox1.Text + "9";
}
else
if (((Button)sender).Name == "button10")
{
if (textBox1.Text == "")
textBox1.Text = "0";
else
textBox1.Text = textBox1.Text + "0";
}
}
public double sayı1gonder()
{
return sayi1 = Convert.ToDouble(textBox1.Text);
}
private **** button12_Click(object sender, EventArgs e)
{
sayı1gonder();
seçilen = 1;
textBox1.Text = "";
}
private **** button11_Click(object sender, EventArgs e)
{
sayi2 = Convert.ToDouble(textBox1.Text);
if (seçilen == 1)
işlem = (sayi1 + sayi2);
if (seçilen == 3)
işlem = sayi1 * sayi2;
if (seçilen == 2)
işlem = sayi1 - sayi2;
if (seçilen == 4)
işlem = sayi1 / sayi2;
textBox1.Text = işlem.ToString();
}
private **** button16_Click(object sender, EventArgs e)
{
textBox1.Clear();
}
private **** button17_Click(object sender, EventArgs e)
{
if (textBox1.Text.Equals(""))
textBox1.Text = "";
else
textBox1.Text = textBox1.Text + ",";
}
private **** button13_Click(object sender, EventArgs e)
{
sayı1gonder();
seçilen = 2;
textBox1.Text = "";
}
private **** button15_Click(object sender, EventArgs e)
{
sayı1gonder();
seçilen = 4;
textBox1.Text = "";
}
private **** button14_Click_1(object sender, EventArgs e)
{
sayı1gonder();
seçilen = 3;
textBox1.Text = "";
}
private **** button18_Click(object sender, EventArgs e)
{
double sinüs;
açı = Convert.ToDouble(textBox1.Text);
acıradyan = açı*Math.PI/180;
sinüs = Math.Sin(acıradyan);
textBox1.Text = sinüs.ToString();
}
private **** button19_Click(object sender, EventArgs e)
{
double cosu;
açı = Convert.ToDouble(textBox1.Text);
acıradyan = açı * Math.PI / 180;
cosu = Math.Cos(acıradyan);
textBox1.Text = cosu.ToString();
}
private **** button20_Click(object sender, EventArgs e)
{
açı = Convert.ToDouble(textBox1.Text);
acıradyan = açı * Math.PI / 180;
tanjı = Math.Tan(acıradyan);
if (açı == 90)
textBox1.Text = "error tan 90 is undefinition";
else
textBox1.Text = tanjı.ToString();
}
private **** button21_Click(object sender, EventArgs e)
{
double cotu;
açı = Convert.ToDouble(textBox1.Text);
acıradyan = açı * Math.PI / 180;
cotu = 1 / (Math.Tan(acıradyan));
if (açı == 0)
textBox1.Text = "error cot 0 is undefinition";
else
if (açı == 90)
textBox1.Text = "0";
else
textBox1.Text = cotu.ToString();
}
private **** button22_Click(object sender, EventArgs e)
{
sayı1gonder();
acıradyan = Math.Asin(sayi1)*180/Math.PI;
textBox1.Text = acıradyan.ToString();
}
private **** button25_Click(object sender, EventArgs e)
{
sayı1gonder();
işlem = Math.Exp(sayi1);
textBox1.Text = işlem.ToString();
}
private **** button26_Click(object sender, EventArgs e)
{
sayı1gonder();
işlem = Math.Sqrt(sayi1);
textBox1.Text = işlem.ToString();
}
private **** button27_Click(object sender, EventArgs e)
{
double.TryParse(textBox1.Text, out sayi1);
sayı1gonder();
işlem=Math.Log10(sayi1);
textBox1.Text=işlem.ToString();
}
private **** button23_Click(object sender, EventArgs e)
{
sayı1gonder();
acıradyan = Math.Acos(sayi1) * 180 / Math.PI;
textBox1.Text = acıradyan.ToString();
}
private **** button24_Click(object sender, EventArgs e)
{
sayı1gonder();
acıradyan = Math.Atan(sayi1) * 180 / Math.PI;
textBox1.Text = acıradyan.ToString();
}
|
|
|
|
|
|
|
|
|
|
|
|