domingo, 18 de septiembre de 2016

ÁREA DE UN TRIÁNGULO


PRÁCTICA #3

ÁREA DE UN TRIÁNGULO

Objetivo: Diseñar una aplicación en C# que calcule el área de un triángulo. Implementar los botones Calcular, Limpiar y Salir.


DISEÑO DEL PROGRAMA


Código del programa

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Práctica_3
{
    public partial class frmAreaTriangulo : Form
    {
        public frmAreaTriangulo()
        {
            InitializeComponent();
        }

        private void btnCalcular_Click(object sender, EventArgs e)
        {
            double a, b, c;
            a = Convert.ToDouble(txtBase.Text);
            b = Convert.ToDouble(txtAltura.Text);
            c = (a * b) / 2;
            txtResultado.Text = Convert.ToString(c);
        }

        private void btnLimpiar_Click(object sender, EventArgs e)
        {
            txtBase.Text = "";
            txtAltura.Text = "";
            txtResultado.Text = "";
        }

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

}

No hay comentarios:

Publicar un comentario