Skip to content

Instantly share code, notes, and snippets.

@godie007
Created May 26, 2012 18:24
Show Gist options
  • Save godie007/2794857 to your computer and use it in GitHub Desktop.
Save godie007/2794857 to your computer and use it in GitHub Desktop.
package Trabajo;
import javax.swing.JOptionPane;
//Main
public class Proyecto {
public static void main(String[] args) {
int operacion = Integer.parseInt(JOptionPane.showInputDialog("Ingrese una opcion \n"
+ "1-Suma \n"
+ "2-Resta \n"
+ "3-Multiplicacion"));
operacionInicio(operacion);
}
//**************************************************************************************************
// metodo para sumar resta o multiplicar
public static void operacionInicio(int operacion) {
if (operacion >= 1 && operacion <= 3) {
int a = Integer.parseInt(JOptionPane.showInputDialog("A"));
int b = Integer.parseInt(JOptionPane.showInputDialog("B"));
switch (operacion) {
case 1: {
System.out.println("Suma: " + (a + b));
break;
}
case 2: {
System.out.println("Resta: " + (a - b));
break;
}
case 3: {
System.out.println("multiplicacion: " + (a * b));
break;
}
}
}else {
JOptionPane.showMessageDialog(null, "Rango Invalido",
"Error!", JOptionPane.ERROR_MESSAGE);
}
}
//*******************************************************************************************
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment