Advertisement
idsystems

CPP_Practica63_Calculadora

Mar 14th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. // Program: calc.cc
  2. // Author:  Yoan Pinzon
  3. // Date:    Agosto 30, 2006
  4.  
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10.    int opc, x, y;
  11.  
  12.    do{
  13.       cout << "====== MENU CALCULADORA ======\n";
  14.       cout << "1.- Sumar\n2.- Restar\n3.- Multiplicar\n4.- Dividir\n0.- Terminar\n";
  15.       cout << "==============================\n";
  16.       cout << "Ingrese su seleccion > "; cin >> opc;
  17.       if(opc>0 && opc <=4){
  18.          cout << "Entre 2 numeros: "; cin >> x >> y;
  19.          switch(opc){
  20.             case 1: cout << x << "+" << y << "=" << x+y << endl; break;
  21.             case 2: cout << x << "-" << y << "=" << x-y << endl; break;
  22.             case 3: cout << x << "*" << y << "=" << x*y << endl; break;
  23.             case 4: cout << x << "/" << y << "=" << float(x)/y << endl;
  24.          }
  25.       }
  26.       else if(opc!=0) cout << opc << " no es valido!, intente nuevamente." << endl;
  27.    }while(opc!=0);
  28.  
  29.    return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement