-
-
Save parzibyte/34106a04ee44ce87dc9d8951293eaa85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void operaciones() { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("Escribe un número:"); | |
int primerNumero = sc.nextInt(); | |
System.out.println("Escribe otro número:"); | |
int segundoNumero = sc.nextInt(); | |
sc.close(); | |
int suma = primerNumero + segundoNumero; | |
int resta = primerNumero - segundoNumero; | |
int multiplicacion = primerNumero * segundoNumero; | |
System.out.printf("Suma: %d. Resta: %d. Multiplicación: %d. ", suma, resta, multiplicacion); | |
if (segundoNumero == 0) { | |
System.out.println("No se puede dividir por cero"); | |
} else { | |
int division = primerNumero / segundoNumero; | |
System.out.printf("División: %d\n", division); | |
} | |
} | |
public static void main(String[] args) { | |
operaciones(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment