21 lines
488 B
Java
21 lines
488 B
Java
import java.util.InputMismatchException;
|
|
import java.util.Scanner;
|
|
public class Aufgabe2 {
|
|
public static void main(String args[]) {
|
|
try {
|
|
System.out.println(berechneDivision(10,0));
|
|
} catch(IllegalArgumentException e) {
|
|
System.out.println(e.getMessage());
|
|
}
|
|
|
|
|
|
}
|
|
public static int berechneDivision(int a, int b){
|
|
if (b == 0){
|
|
throw new IllegalArgumentException("Der Nenner darf nicht Null sein");
|
|
}
|
|
int c = a/b;
|
|
return c;
|
|
}
|
|
}
|