Badyx

[C++] Calculadora

May 29th, 2013
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. /*
  4. [img]http://img843.imageshack.us/img843/8658/calculon.png[/img]
  5. [img]http://img197.imageshack.us/img197/1995/calculo2.bmp[/img]
  6. */
  7. int main()        
  8. {
  9.     using namespace std;
  10.     int numero1;
  11.     int numero2;
  12.     int Accion;
  13.     cout << "******************************************\n";
  14.     cout << "* Bienvenidos a la calculadora The BadyX *\n";
  15.     cout << "******************************************\n";
  16.     printf( "Que desea hacer?\n\n1) - Sumar\n2) - Restar\n3) - Multiplicar\n4) - Divir\n");
  17.     cin  >> Accion;
  18.     /*if(Accion < 0 || Accion > 4)
  19.     {
  20.     cout << "\nError al seleccionar la operacion a realizar.\n"<<     endl;
  21.     }*/
  22.     switch(Accion)
  23.     {                  
  24.     case 1:     cout << "Seleccionaste la operacion sumar"           <<  endl;          break;  
  25.     case 2:     cout << "Seleccionaste la operacion restar"          <<  endl;          break;
  26.     case 3:     cout << "Seleccionaste la operacion multiplicar"     <<  endl;          break;
  27.     case 4:     cout << "Seleccionaste la operacion dividir"         <<  endl;          break;
  28.     default:    cout << "\nSe a encontrado un error\n"               <<  endl;
  29.     }  
  30.     cout << "Introduzca el primer numero:\n";
  31.     cin  >> numero1;    
  32.     cout << "Introduzca el segundo numero:\n";
  33.     cin  >> numero2;    
  34.     cout << "\nNumero 1:\t" << numero1;
  35.     cout << "\nNumero 2:\t" << numero2;
  36.     switch(Accion)
  37.     {                  
  38.     case 1:     cout << "\n\t  +   ----\nResultado:\t"         <<  numero1 + numero2;      break;
  39.     case 2:     cout << "\n\t  -   ----\nResultado:\t"         <<  numero1 - numero2;      break;
  40.     case 3:     cout << "\n\t  *   ----\nResultado:\t"         <<  numero1 * numero2;      break;
  41.     case 4:     cout << "\n\t  /   ----\nResultado:\t"         <<  numero1 / numero2;      break;
  42.     default:    cout << "\nSe a encontrado un error\n"<<     endl;
  43.     }  
  44.     cout << "\n\n"  <<     endl;    
  45.     system("pause");
  46.  
  47.     return 0;  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment