Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. import com.sun.xml.internal.ws.util.StringUtils;
  2.  
  3. import java.text.ParseException;
  4. import java.text.SimpleDateFormat;
  5. import java.time.LocalDate;
  6. import java.time.LocalDateTime;
  7. import java.time.Year;
  8. import java.time.format.DateTimeFormatter;
  9. import java.util.Calendar;
  10. import java.util.Date;
  11. import java.util.Locale;
  12. import java.util.Scanner;
  13.  
  14. import static com.sun.xml.internal.ws.util.StringUtils.capitalize;
  15. import static java.time.temporal.ChronoUnit.DAYS;
  16.  
  17. public class Ihor {
  18.  
  19.     public static void main(String[] args) throws ParseException {
  20.         while(true) {
  21.             Scanner scanner = new Scanner(System.in);
  22.             int x = Integer.parseInt(scanner.nextLine());
  23.             int y = Integer.parseInt(scanner.nextLine());
  24.  
  25.             try {
  26.                 System.out.println(divide(x, y));
  27.                 return;
  28.             } catch (IllegalArgumentException ex) {
  29.                 System.out.println(ex.getMessage());
  30.                 System.out.println("Введи валидные аргументы");
  31.             }
  32.         }
  33.  
  34.     }
  35.  
  36.     private static long divide(int x, int y) {
  37.         try {
  38.             return x / y;
  39.         } catch (ArithmeticException ex) {
  40.             throw new IllegalArgumentException("Я тебя сейчас сам на 0 поделю!");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement