/* File: Test0.java -- March 2018 */ package l03; /** * Tests whether a number is a perfect square using a rather inefficient * algorithm. * * @author Michael Albert * */ public class Test0 implements SquareTest{ long loops = 0; long n; public boolean isSquare(long n) { this.n = n; loops = 0; for(long i = 1; i <= n; i++) { loops++; // For reporting purposes if (i*i == n) return true; } return false; } public String report() { return "A0 loops for input " + n + " was " + loops; } public static void main(String[] args) { long n = Long.parseLong(args[0]); Test0 test = new Test0(); System.out.println(test.isSquare(n)); System.out.println(test.report()); } }