sábado, 18 de octubre de 2014

Temperaturas: Grados centigrados, fahrenheit, rankine y kelvin


 private void TGCYF_Load(object sender, EventArgs e)
        {

        }

        private void Clear_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";
            textBox6.Text = "";
            textBox7.Text = "";
            textBox8.Text = "";
            textBox9.Text = "";
            textBox10.Text = "";
            textBox11.Text = "";
            textBox12.Text = "";
            textBox13.Text = "";
            textBox14.Text = "";
            textBox15.Text = "";
            textBox16.Text = "";
         
        }

        private void Close_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            double C, F, K, R;
            C = double.Parse(textBox1.Text);
            F = C * 9 / 5 + 32;
            K = C + 273.15;
            R = (9 * C / 5) + 491.67;
            textBox2.Text = F.ToString();
            textBox3.Text = K.ToString();
            textBox4.Text = R.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            double R, C, F, K;
            R = double.Parse(textBox5.Text);
            C = 5 * (R - 491.67) / 9;
            F = R - 459.67;
            K = 5 * (R - 491.67) / 9 + 273.15;
            textBox6.Text = C.ToString();
            textBox7.Text = F.ToString();
            textBox8.Text = K.ToString();

        }

        private void button3_Click(object sender, EventArgs e)
        {
            double F, C, K, R;
            F = double.Parse(textBox9.Text);
            C = (5 * (F - 32)) / 9;
            K = 5 * (F - 32) / 9 + 273.15;
            R = F + 459.67;
            textBox10.Text = C.ToString();
            textBox11.Text = K.ToString();
            textBox12.Text = R.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            double K, C, F, R;
            K = double.Parse(textBox13.Text);
            C = K - 273.15;
            F = 9 * (K - 273.15) / 5 + 32;
            R = 9 * (K - 273.15) / 5 + 491.67;
            textBox14.Text = C.ToString();
            textBox15.Text = F.ToString();
            textBox16.Text = R.ToString();
        }
    }
}

Área y Volumen de un prisma rectangular


 private void button3_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {

            double h, L, Area, Volumen;
            h = double.Parse(textBox1.Text);
            L = double.Parse(textBox2.Text);
            Area = 2 * L * (L + 2 * h);
            Volumen = (L * L) * h;
            textBox3.Text = Area.ToString();
            textBox4.Text = Volumen.ToString();

        }

        private void PrismaCuadrangular_Load(object sender, EventArgs e)
        {

        }
    }
}

Triangulo isoceles


 private void button1_Click(object sender, EventArgs e)
        {
            double b, h;
            b = Convert.ToInt32(textBox1.Text);
            h = Convert.ToInt32(textBox2.Text);
            textBox3.Text = String.Format("{0:F2}", (b * h) / 2);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}

Área del circulo

 private void button1_Click(object sender, EventArgs e)
        {
            int radio;

const double pi= 3.1416;
//Teclea los datos de entrada
radio= Convert.ToInt32 (textBox1.Text);
textBox2.Text=String.Format("{0:F2}",pi*radio*radio);

        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Areadelcirculo_Load(object sender, EventArgs e)
        {

        }
    }
}

Calculadora avanzada


}
        bool secuencia =true;
        string operacion;
        double num1, num2, resultado;
        //Numeros de la calculadora
        private void btnone_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "1";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "1";
            }
        }

             
        private void btntwo_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "2";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "2";
            }
        }

        private void btnthree_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
         {
                txtDisplay.Text = "";
                txtDisplay.Text = "3";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "3";
            }
        }

        private void btnfour_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "4";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "4";
            }
        }

        private void btnfive_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "5";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "5";
            }
        }

        private void btnsix_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "6";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "6";
            }
        }

        private void btnseven_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "7";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "7";
            }
        }

        private void btneight_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "8";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "8";
            }
        }

        private void btnnine_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = "9";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "9";
            }
        }

        private void btnzero_Click(object sender, EventArgs e)
        {
            if (txtDisplay.Text == "0")
            {
                return;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + "0";
            }
        }
        //Fin de los numeros de la calculadora
        //Inicio de los botones de operaciones
        private void btnpoint_Click(object sender, EventArgs e)
        {
            if (secuencia == true)
            {
                txtDisplay.Text = "";
                txtDisplay.Text = ".";
                secuencia = false;
            }
            else
            {
                txtDisplay.Text = txtDisplay.Text + ".";
            }
        }

        private void btnclear_Click(object sender, EventArgs e)
        {
            txtDisplay.Clear();
        }

        private void btnclose_Click(object sender, EventArgs e)
        {
            Close();
        }
        private void btnequals_Click(object sender, EventArgs e)
        {
            num2 = Double.Parse(txtDisplay.Text);
            if (operacion == "+")
            {
                resultado = num1 + num2;
                txtDisplay.Text = resultado.ToString();
                secuencia = true;
            }
            if (operacion == "-")
            {
                resultado = num1 - num2;
                txtDisplay.Text = resultado.ToString();
                secuencia = true;
            }
            if (operacion == "*")
            {
                resultado = num1 * num2;
                txtDisplay.Text = resultado.ToString();
                secuencia = true;
            }
            if (operacion == "/")
            {
                resultado = num1 / num2;
                txtDisplay.Text = resultado.ToString();
                secuencia = true;
            }

        }
        private void btnplus_Click(object sender, EventArgs e)
        {
            operacion = "+";
            num1 = double.Parse(txtDisplay.Text);
            secuencia = true;


        }
        private void btnminus_Click(object sender, EventArgs e)
        {
            operacion = "-";
            num1 = double.Parse(txtDisplay.Text);
            secuencia = true;

        }
        private void btnmultiplication_Click(object sender, EventArgs e)
        {
            operacion = "*";
            num1 = double.Parse(txtDisplay.Text);
            secuencia = true;

        }
        private void btndivision_Click(object sender, EventArgs e)
        {
            operacion = "/";
            num1 = double.Parse(txtDisplay.Text);
            secuencia = true;

        }
        private void btnporcentage_Click(object sender, EventArgs e)
        {
            num1 = double.Parse(txtDisplay.Text);
            resultado = Math.Sqrt(num1 * num1);
            txtDisplay.Text = resultado.ToString();
            secuencia = true;

        }
        private void btnraiz_Click(object sender, EventArgs e)
        {
            num1 = double.Parse(txtDisplay.Text);
            resultado = Math.Sqrt (num1);
            txtDisplay.Text = resultado.ToString();
            secuencia = true;
        }

        private void txtDisplay_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

Calculadora sencilla


double total1 = 0;
        private void btnsuma_Click(object sender, EventArgs e)
        {
            total1 = total1 + double.Parse(txtDisplay.Text);
            txtDisplay.Clear();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btn1_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnone.Text;
        }

        private void btntwo_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btntwo.Text;
        }

        private void btnthree_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnthree.Text;
        }

        private void btnfour_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnfour.Text;
        }

        private void btnfive_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnfive.Text;
        }

        private void btnsix_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnsix.Text;
        }

        private void btnseven_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnseven.Text;
        }

        private void btneight_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btneight.Text;
        }

        private void btnnine_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnnine.Text;
        }

        private void btnzero_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnzero.Text;
        }
        Double total2 = 0;
        private void btniguals_Click(object sender, EventArgs e)
        {
            total2= total1+double.Parse(txtDisplay.Text);
            txtDisplay.Text = total2.ToString();
            total1 = 0;
        }

        private void btnclear_Click(object sender, EventArgs e)
        {
            txtDisplay.Clear();
        }

        private void Close_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnpoint_Click(object sender, EventArgs e)
        {
            txtDisplay.Text = txtDisplay.Text + btnpoint.Text;
        }
    }
}


División de dos valores


private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c;
            string r;
            a = Convert.ToInt32(textBox1.Text);
            b = Convert.ToInt32(textBox2.Text);
            c = a / b;
            r = (string.Format("{0:F2}", c));
            textBox3.Text = r;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }
    }
}

Multiplicación de dos valores


  private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c;
            string r;
            a = Convert.ToInt32(textBox1.Text);
            b = Convert.ToInt32(textBox2.Text);
            c = a * b;
            r = (string.Format("{0:F2}", c));
            textBox3.Text = r;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }
    }
}

Resta de dos valores


private void button1_Click(object sender, EventArgs e)
        {
            int a, b, c;
            string r;
            a = Convert.ToInt32(textBox1.Text);
            b = Convert.ToInt32(textBox2.Text);
            c = a - b;
            r = (string.Format("{0:F2}", c));
            textBox3.Text = r;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }
    }
}

Suma de dos valores


 private void button1_Click(object sender, EventArgs e)
        {
int a,b,c;
string r;
a= Convert.ToInt32(textBox1.Text);
b= Convert.ToInt32(textBox2.Text);
c=a+b;
r=(string.Format("{0:F2}",c));
textBox3.Text=r;

        }

        private void button2_Click(object sender, EventArgs e)
        {
Close();

        }

        private void button3_Click(object sender, EventArgs e)
        {
textBox1.Text="";
textBox2.Text="";
textBox3.Text="";
       
        }
    }
}