Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ejercicio1;
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class e1 {
- public static void main(String[] args) {
- double a, b, c = 0;
- boolean cont = false;
- while (cont==false){
- Scanner entrada = new Scanner(System.in);
- try {
- System.out.println("Introduzca a: ");
- a = entrada.nextDouble();
- System.out.println("Introduzca b: ");
- b = entrada.nextDouble();
- cont= true;
- c=a/b;
- System.out.println(c);
- }
- catch (InputMismatchException e){
- System.out.println("Debes introducir un número");
- }
- catch (ArithmeticException e){
- System.out.println("No se puede dividir entre 0");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment