Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public class lingkaran{
  2.  
  3. private double radius;
  4.  
  5. public lingkaran(double radius){
  6.  
  7. this.radius=radius;
  8.  
  9. }
  10.  
  11. public void Luas(){
  12.  
  13. double luas= 3.14*radius*radius;
  14.  
  15. System.out.println(“Luas lingkaran: “+luas);
  16.  
  17. }
  18.  
  19. public void Keliling(){
  20.  
  21. double keliling= 2.0*3.14*radius;
  22.  
  23. System.out.println(“Keliling Lingkaran: “+keliling);
  24.  
  25. }
  26.  
  27. public static void main(String[]args)throws Exception{
  28.  
  29. DataInputStream dis= new DataInputStream(System.in);
  30.  
  31. System.out.print(“input radius: “);
  32.  
  33. String input= dis.readLine();
  34.  
  35. double i= Double.parseDouble(input);
  36.  
  37. lingkaran A= new lingkaran(i);
  38.  
  39. A.Luas();
  40.  
  41. A.Keliling();
  42.  
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement