SoloCodigo

Programación General => C/C++ => Mensaje iniciado por: davidjas en Martes 16 de Marzo de 2010, 20:05

Título: Calculadora
Publicado por: davidjas en Martes 16 de Marzo de 2010, 20:05
Estoy haciendo una calculadora en c# y necesito que sume mas de dos numero:
ejemplo:
5+5+5=15
y esto hace la mia:
5+5+5=10

manden solucion
new (http://www.google.com/search?q=new+msdn.microsoft.com) operacion();
  •            
  •    
  •            
  •  
  •             if (Operacion == 1)
  •             {
  •                 Respuesta = miinterface.suma(sPrimer, sSegundo);
  •                 cmdresultado.Text = Convert.ToString(Respuesta);
  •                
  •                
  •             }
  •             if (Operacion == 2)
  •             {
  •                 Respuesta = miinterface.resta(sPrimer, sSegundo);
  •                 cmdresultado.Text = Convert.ToString(Respuesta);
  •                
  •             }
  •  
  •             if (Operacion == 3)
  •             {
  •                 Respuesta = miinterface.multi(sPrimer, sSegundo);
  •                 cmdresultado.Text = Convert.ToString(Respuesta);
  •                
  •             }
  •  
  •             if (Operacion == 4)
  •             {
  •                 Respuesta = miinterface.div(sPrimer, sSegundo);
  •                 cmdresultado.Text = Convert.ToString(Respuesta);
  •                
  •             }
  •  
  •         }
  •  
  •         private void button1_Click(object sender, EventArgs e)
  •         {
  •             punto = false;
  •             cmdresultado.Text = "";
  •         }
  •  
  •         private void Form1_Load(object sender, EventArgs e)
  •         {
  •  
  •         }
  •  
  •        
  •  
  •        
  •     }
  •  
  •     interface Ioperacion
  •     {
  •         double suma(double sPrimer, double sSegundo);
  •         double resta(double sPrimer, double sSegundo);
  •         double multi(double sPrimer, double sSegundo);
  •         double div(double sPrimer, double sSegundo);
  •     }
  •  
  •     class operacion : Ioperacion
  •     {
  •         double Res;
  •      
  •         public double suma(double sPrimer, double sSegundo)
  •         {
  •            
  •             Res = sPrimer + sSegundo;
  •             return Res;
  •         }
  •  
  •         public double resta(double sPrimer, double sSegundo)
  •         {
  •             Res = sPrimer - sSegundo;
  •             return Res;
  •         }
  •  
  •         public double multi(double sPrimer, double sSegundo)
  •         {
  •             Res = sPrimer * sSegundo;
  •             return Res;
  •         }
  •  
  •         public double div(double sPrimer, double sSegundo)
  •         {
  •             Res = sPrimer / sSegundo;
  •             return Res;
  •         }
  •     }
  •  
  •      
  •  
  •    
  •  
  •        
  •  
  •        
  • }
  •  
  • [/code]