Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myapplication
- import java.lang.ArithmeticException
- import java.lang.Exception
- import java.lang.NumberFormatException
- fun main() {
- println("Please Enter Two Divisible Numbers")
- try {
- val num1 = readLine().toString().toInt()
- val num2 = readLine().toString().toInt()
- var result = num1 / num2
- println("The result is ${result}")
- }
- catch (e:ArithmeticException)
- {
- println("Not Divisible By 0")
- }
- catch (e:NumberFormatException)
- {
- println("Invalid Number Entered")
- }
- finally {
- println("This Code Will ALWAYS Execute!!")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement