My code does not work
I am trying to write a method that determines if the square of the age of a person is equal to the current year. For example a man was aged 43 in 1849 and the square of 43 is 1849. Below is my code for it but I dont know why my exception is not working because it is assumed that no body can live past 123 years
public class Augustus { private int year; private final static int RANGEOFLIVING=124; public static void main(String[] args) { Augustus y = new Augustus(1806); System.out.println( y.isAlive());
} public Augustus(int n){ year= n;
}
public int SquareOfAge(int z){
return z * z ;
}
public boolean isAlive(){
for(int i=1;i<RANGEOFLIVING;i++)
if( i *i==this.year++)
return true;
return false;
}
}
3 comments
[ 2.7 ms ] story [ 18.7 ms ] thread