Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. package com.example.myapplication
  2.  
  3. import java.lang.ArithmeticException
  4. import java.lang.Exception
  5. import java.lang.NumberFormatException
  6.  
  7. fun main() {
  8. println("Please Enter Two Divisible Numbers")
  9. try {
  10. val num1 = readLine().toString().toInt()
  11. val num2 = readLine().toString().toInt()
  12. var result = num1 / num2
  13. println("The result is ${result}")
  14. }
  15. catch (e:ArithmeticException)
  16. {
  17. println("Not Divisible By 0")
  18. }
  19. catch (e:NumberFormatException)
  20. {
  21. println("Invalid Number Entered")
  22. }
  23. finally {
  24. println("This Code Will ALWAYS Execute!!")
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement