Código de C sharp - Código C# - Calculadora Simple

Imágen de perfil

Código C# - Calculadora Simplegráfica de visualizaciones


C sharp

Actualizado el 28 de Septiembre del 2015 por Chuy (Publicado el 26 de Septiembre del 2015)
130.288 visualizaciones desde el 26 de Septiembre del 2015
Screenshot_1


Código para realizar una simple calculadora en Visual Studio C#, también contiene una opción para imprimir nuestro resultado en un documento .txt.

Requerimientos

Visual Studio 2013

1.0
estrellaestrellaestrellaestrellaestrella(9)

Actualizado el 28 de Septiembre del 2015 (Publicado el 26 de Septiembre del 2015)gráfica de visualizaciones de la versión: 1.0
130.289 visualizaciones desde el 26 de Septiembre del 2015
estrellaestrellaestrellaestrellaestrella
estrellaestrellaestrellaestrella
estrellaestrellaestrella
estrellaestrella
estrella

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
using System.IO;
 
namespace Calculadora
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        double a;
        double b;
        string c;
 
        private void btn1_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "1";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "1" ;
            }
        }
 
        private void btn2_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "2";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "2";
            }
        }
 
        private void btn3_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "3";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "3";
            }
        }
 
        private void btn4_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "4";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "4";
            }
        }
 
        private void btn5_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "5";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "5";
            }
        }
 
        private void btn6_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "6";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "6";
            }
        }
 
        private void btn7_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "7";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "7";
            }
        }
 
        private void btn8_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "8";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "8";
            }
        }
 
        private void btn9_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "9";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "9";
            }
        }
 
        private void btn0_Click(object sender, EventArgs e)
        {
            if (txtpantalla.Text == "")
            {
                txtpantalla.Text = "0";
            }
            else
            {
                txtpantalla.Text = txtpantalla.Text + "0";
            }
        }
 
        private void btndivision_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(this.txtpantalla.Text);
            c = "/";
            this.txtpantalla.Clear();
            this.txtpantalla.Focus();
        }
 
        private void btnmultiplicacion_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(this.txtpantalla.Text);
            c = "*";
            this.txtpantalla.Clear();
            this.txtpantalla.Focus();
        }
 
        private void btnresta_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(this.txtpantalla.Text);
            c = "-";
            this.txtpantalla.Clear();
            this.txtpantalla.Focus();
        }
 
        private void btnsuma_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble(this.txtpantalla.Text);
            c = "+";
            this.txtpantalla.Clear();
            this.txtpantalla.Focus();
        }
 
        private void btnpunto_Click(object sender, EventArgs e)
        {
            if (this.txtpantalla.Text.Contains('.')==false)
            {
                this.txtpantalla.Text = this.txtpantalla.Text + ".";
            }
 
 
        }
 
        private void btnigual_Click(object sender, EventArgs e)
        {
            b = Convert.ToDouble(this.txtpantalla.Text);
            switch (c)
            {
                case "+":
                    this.txtpantalla.Text  = Convert.ToString (b + a);
                    break;
 
                case "-":
                    this.txtpantalla.Text = Convert.ToString(b - a);
                    break;
 
                case "*":
                    this.txtpantalla.Text = Convert.ToString(b * a);
                    break;
 
                case "/":
                    this.txtpantalla.Text = Convert.ToString(b / a);
                    break;
            }
 
 
        }
 
        private void btnprint_Click(object sender, EventArgs e)
        {
            StreamWriter Archivo = new StreamWriter("Ruta\\archivo.txt");
            Archivo.WriteLine("Operaciones: " + a + c + b + "=" + this.txtpantalla.Text);
            Archivo.Flush();
            Archivo.Close();
 
            System.Diagnostics.Process.Start("Ruta\\archivo.txt");
        }
 
        private void btnlimpiar_Click(object sender, EventArgs e)
        {
            a = Convert.ToDouble("");
            b = Convert.ToDouble("");
            this.txtpantalla.Text = "";
 
        }
    }
}



Comentarios sobre la versión: 1.0 (9)

3 de Mayo del 2017
estrellaestrellaestrellaestrellaestrella
No ha dejado ningún comentario
Responder
gerret
9 de Mayo del 2017
estrellaestrellaestrellaestrellaestrella
Excelente aporte
Responder
Charls
11 de Marzo del 2018
estrellaestrellaestrellaestrellaestrella
Muy buena y completa. Cómo podría hacer el botón de borrar o retroceso que algunas calculadoras tienen para borrar el último caracter??
Responder
Carlos
22 de Marzo del 2018
estrellaestrellaestrellaestrellaestrella
Muy buen aporte

me podrías ayudar con este proyecto:

1 parate: Consiste en realizar una Nómina para Colombia con las Normas y tarifas del 2018 en C# - ASP.SET, se realizará la Nómina para 1 solo Empleado cuyos datos de entrada serán CEDULA - SUELDO - DÍAS - #HRN #HED #HEN #HEDD #HEDN un Botón CALCULAR y debe aparecer toda la Nómina del Colaborador.

2 parte: Para Sueldo entre 1 Salario Mínimo legal vigente en el 2018
y 3 Salarios mínimos se les dará una bonificación del 15%
y para los sueldos que superen los 3 Salarios se les dará una bonificación del 12.5%
Tenga en cuenta que la Bonificación debe sumar al Total Devengado y obviamente al Neto a pagar.
Mostrar en un TextBox el Calculo de la Bonificación.

3 parte: consiste en realizar y entregar un Proyecto Final de Nómina 2018 para Colombia para 21 Empleados Que permita Crear Empleados, Buscar por Numero de Cedula y traer toda la informacion del Empleado liquidada, Minimo debe presentar 2 Formularios, tener en cuenta que deben permitir modificar un registro de los datos básicos, no permitir modificar los Datos Calculados y por último eliminar Registros. Después de realizar los Procesos de Creacion, Modificacion y eliminacion se debe actualizar la informacion.
Responder
David
3 de Julio del 2018
estrellaestrellaestrellaestrellaestrella
El codigo tiene dos errores
en la division y la resta las variables van al reves
Responder
Jose
5 de Marzo del 2020
estrellaestrellaestrellaestrellaestrella
Porque está mal, x que a es el primer número en digitar y b el segundo. line 195?
Responder
ServidorAnonimo
27 de Octubre del 2020
estrellaestrellaestrellaestrellaestrella
En la línea 188 - 196, tiene el mismo error. Cambia el orden de la operación y como resultado no se obtiene el esperado, un ejemplo es que si ingresas el 2 primero, seleccionas resta y luego ingresas 3 lo que obtienes es 1 y esto no sería correcto porque lo que queremos es 2 - 3 no 3 - 2. Algo parecido sucede con la división, quieres hacer esto 10 / 2, pero él te devolverá 2 / 10.
Responder
17 de Marzo del 2019
estrellaestrellaestrellaestrellaestrella
la suma de 3 + 1,5 =18????
Responder
12 de Mayo del 2020
estrellaestrellaestrellaestrellaestrella
muy bueno
Responder

Comentar la versión: 1.0

Nombre
Correo (no se visualiza en la web)
Valoración
Comentarios...
CerrarCerrar
CerrarCerrar
Cerrar

Tienes que ser un usuario registrado para poder insertar imágenes, archivos y/o videos.

Puedes registrarte o validarte desde aquí.

Codigo
Negrita
Subrayado
Tachado
Cursiva
Insertar enlace
Imagen externa
Emoticon
Tabular
Centrar
Titulo
Linea
Disminuir
Aumentar
Vista preliminar
sonreir
dientes
lengua
guiño
enfadado
confundido
llorar
avergonzado
sorprendido
triste
sol
estrella
jarra
camara
taza de cafe
email
beso
bombilla
amor
mal
bien
Es necesario revisar y aceptar las políticas de privacidad

http://lwp-l.com/s3286