Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main
- {
- public static void main(String[] args) {
- Scanner fn = new Scanner(System.in);
- System.out.println("Enter a number ");
- int n = fn.nextInt();
- if(n<0 || n>100){
- throw new ArithmeticException("Number is smaller than 0 and greater than 100");
- }
- else {
- System.out.println("Your input is fine");
- }
- }
- }
- /*
- Enter a number
- -1
- Exception in thread "main" java.lang.ArithmeticException: Number is smaller than 0 and greater than 100
- at Main.main(Main.java:10)
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement