Você está na página 1de 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package javaapplication1;
import javax.swing.JOptionPane;
/**
*
* @author Bruno Arruda
*/
public class Main {
public static int soma(int a, int b){
int c = a + b;
return c;
}
public static int sub(int a, int b){
int c = a - b;
return c;
}
public static int mult(int a, int b){
int c = a * b;
return c;
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int numero1 = 1;
int numero2 = 2;
String option, continuar, n1, n2;
int s = 0,op,c;
do{
option =
JOptionPane.showInputDialog("\t Menu\n"
+ "1-Soma\n2-Subtração\n"
+ "3-Multiplicação\n0-sair\n\nEntre com a opção desejada");
op = Integer.parseInt(option);
if(op == 1){
n1=
JOptionPane.showInputDialog("Entre com o primeiro numero:");
numero1 = Integer.parseInt(n1);
n2=
JOptionPane.showInputDialog("Entre com o segundo numero:");
numero2 = Integer.parseInt(n2);
s = soma(numero1, numero2);
JOptionPane.showMessageDialog(null,"A soma é:" +s);
}
if(op == 2){
n1=
JOptionPane.showInputDialog("Entre com o primeiro numero:");
numero1 = Integer.parseInt(n1);
n2=
JOptionPane.showInputDialog("Entre com o primeiro numero:");
numero2 = Integer.parseInt(n2);
s = sub(numero1, numero2);
JOptionPane.showMessageDialog(null,"A subtração é:" +s);
}
if(op == 3){
n1=
JOptionPane.showInputDialog("Entre com o primeiro numero:");
numero1 = Integer.parseInt(n1);
n2=
JOptionPane.showInputDialog("Entre com o primeiro numero:");
numero2 = Integer.parseInt(n2);
s = mult(numero1, numero2);
JOptionPane.showMessageDialog(null,"A multiplicação é:" +s);
}
if (op == 0){
JOptionPane.showMessageDialog(null,"Obrigado!",null,JOptionPane.INFO
RMATION_MESSAGE);
System.exit(0);
}
continuar =
JOptionPane.showInputDialog("Deseja continuar"
+ "<1-sim 2-nao>");
c = Integer.parseInt(continuar);
}while(c == 1);
}
}

Você também pode gostar