Unknown
LISTING PROGRAM

package exception1;
import java.io.*;

public class Exception1 {
    private FileReader in;
    public Exception1(String filename){
        try {
            in=new FileReader(filename);
        } catch (java.io.FileNotFoundException ex){
            System.err.println("File tidak ditemukan");
            System.exit(0);
        }
    }

    public static void main(String[] args) {
        Exception1 ex=new Exception1("/etc/password");
    }
}

package contoh1;
import java.util.InputMismatchException;
import java.util.Scanner;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
public class Contoh1 {
    public static void main(String[] args) {
        // TODO code application logic here
        float a,b;
       
        System.out.print("Bilangan Penyebut : ");
        Scanner input=new Scanner (System.in);
        a=input.nextInt();
       
        System.out.print("Bilangan Pembagi  : ");
        input=new Scanner (System.in);
        b=input.nextInt();
       
        try
        {
            float hitung=a/b;
            System.out.println("Hasil : " + hitung);
        }
        catch (ArithmeticException e)
        {
            System.out.println(e.toString());
        }
        catch (InputMismatchException e)
        {
            System.out.println(e.toString());
        }
    }
}

package contoh1;
import java.util.InputMismatchException;
import java.util.Scanner;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
public class Contoh1 {
    public static void main(String[] args) {
        // TODO code application logic here
        float a,b;
       
        System.out.print("Bilangan Penyebut : ");
        Scanner input=new Scanner (System.in);
        a=input.nextInt();
       
        System.out.print("Bilangan Pembagi  : ");
        input=new Scanner (System.in);
        b=input.nextInt();
       
        try
        {
            float hitung=a/b;
            System.out.println("Hasil : " + hitung);
        }
        catch (ArithmeticException e)
        {
            System.out.println(e.toString());
        }
        catch (InputMismatchException e)
        {
            System.out.println(e.toString());
        }
    }
}
Label: edit post
0 Responses

Posting Komentar