Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Pada program ini akan meminta user untuk memasukkan 2 integer yang nanti
- * akan dibagi. Lalu, akan dicoba apakah terdapat error yang terjadi dengan
- * menggunakan exception handling metode try catch
- *
- * @author Daffa Tristan Firdaus
- * @version 0.1
- */
- import java.util.*;
- public class Pecahan
- {
- public static void main(String[] args)
- {
- Scanner S = new Scanner(System.in);
- System.out.println("Masukkan Integer :");
- int pembilang = S.nextInt();
- System.out.println("Masukkan Integer :");
- int penyebut = S.nextInt();
- System.out.println("Hasil :");
- try{
- System.out.println(pembilang + "/" + penyebut +
- " = " + pembilang/penyebut);
- }
- catch(ArithmeticException ex){
- System.out.println(pembilang + "/" + penyebut +
- " = " + "undefined");
- }
- }
- }
Add Comment
Please, Sign In to add comment