Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class kelilingLingkaran
- {
- public static void main(String args[])
- {
- Scanner input = new Scanner (System.in);
- double pi = 3.14;
- System.out.print("Masukkan nilai jari-jari lingkaran : ");
- int r = input.nextInt();
- try
- {
- if(r<=0)
- {
- throw new ArithmeticException();
- }
- double keliling = 2*pi*r;
- System.out.print("Keliling lingkaran adalah : ");
- System.out.println(keliling);
- }
- catch(ArithmeticException exception){
- System.err.printf("%nException: %s%n", exception);
- System.out.println("Nilai jari-jari tidak boleh nol atau negatif");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement