Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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.
- */
- package javaapplication11;
- import java.util.Scanner;
- /**
- *
- * @author educacionit
- */
- public class JavaApplication11 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner teclado = new Scanner(System.in);
- /*
- int edad;
- edad = teclado.nextInt();//si necesito que el usuario ingrese un numero
- String usuario = teclado.next();//se utiliza para el string
- */
- int n1, int n2;
- System.out.println("Ingrese primer numero");
- n1=teclado.nextInt();
- System.out.println("Ingrese segundo numero");
- n2=teclado.nextInt();
- System.out.println("\n1. suma \n2. resta\n3. multiplica\n4. divide");
- int opcion=teclado.nextInt();
- switch(opcion){
- case 1:
- System.out.println("Suma: " + (n1+n2));
- break;
- case 2:
- System.out.println("Resta: "+ (n1-n2));
- break;
- case 3:
- System.out.println("Producto: "+ (n1*n2));
- break;
- case 4:
- System.out.println("Division: "+ (n1/n2));
- break;
- default:
- System.out.println("Opcion invalida");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement