Está en la página 1de 3

C:/Users/ANGIE VARGAS/Documents/NetBeansProjects/ifanidado/src/NewClass.

java

import java.util.Scanner;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author ANGIE VARGAS
*/
public class NewClass {

public static void main(String[] args) {


//inicio
Scanner entrada = new Scanner(System.in);
int result = 0;
int opcionMenu;
opcionMenu = 0;

System.out.println("Escoja una de las siguientes opciones ");


System.out.println("Si desea sumar ingrese 1 ");
System.out.println("Si desea restar ingrese 2");
System.out.println("Si desea multiplicar ingrese 3 ");
System.out.println("Si desea dividir ingrese 4 ");

opcionMenu = entrada.nextInt();

System.out.println("Digite el primer dato");


int uno = entrada.nextInt();
System.out.println("Digite el segundo dato");
int dos = entrada.nextInt();

if (opcionMenu != 1) if (opcionMenu == 2) {
System.out.println("Usted selecciono la opción resta ");
result = uno - dos;

} else if (opcionMenu == 3) {
System.out.println("Usted selecciono la opción mulimplicación ");

1.1 of 4 2021.03.24 22:33:51


C:/Users/ANGIE VARGAS/Documents/NetBeansProjects/ifanidado/src/NewClass.java
result = uno * dos;

} else if (opcionMenu == 4) {
System.out.println("Usted selecciono la opción division ");
if (dos == 0) {
opcionMenu = -1;
} else {
result = uno / dos;

} else {
System.out.println("Usted selecciono la opción de resta suma ");
result = uno + dos;
}

if (opcionMenu >= 1 && opcionMenu <= 4) {


System.out.println("el resultado es: " + result);

} else if (opcionMenu == -1) {


System.out.println("No es posible dividir entre cero (0)");
} else {
System.out.println("no se ha seleccionado una opcion correcta");
}
}

2.1 of 4 2021.03.24 22:33:51

También podría gustarte