miércoles, 14 de septiembre de 2016

SUMA DE DOS NÚMEROS


PRÁCTICA #2

SUMA DE DOS NÚMEROS

Objetivo: Diseñar en C# un programa que pida dos números y calcule la suma. Además, implementar dos botones, uno para que limpie el textbox y otro para que termine el programa.


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

        private void Calcular_Click(object sender, EventArgs e)
        {
            double a, b, c;
            a = Convert.ToDouble(txtPrimero.Text);
            b = Convert.ToDouble(txtSegundo.Text);
            c = a + b;
            txtResultado.Text = Convert.ToString(c);
        }

        private void Limpiar_Click(object sender, EventArgs e)
        {
            txtPrimero.Text = "";
            txtSegundo.Text = "";
            txtResultado.Text = "";
        }

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

No hay comentarios:

Publicar un comentario