madhawaseeeee

simpleroottester

Sep 17th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1.  
  2. class SimpleRootTester implements RootTestable {
  3.  
  4.     public void testRoot(int number) {
  5.  
  6.         double sqrt = Math.sqrt(number);
  7.         int x = (int) sqrt;
  8.         if (Math.pow(sqrt, 2) == Math.pow(x, 2)) {
  9.             System.out.println("perfect squre");
  10.         }else{
  11.             System.out.println("not a perfect squre");
  12.         }
  13.     }
  14.     public static void main(String[] args) {
  15.        
  16.         SimpleRootTester srt=new SimpleRootTester ();
  17.         srt.testRoot(100);
  18.         srt.testRoot(10);
  19.        
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment