r/javahelp • • Oct 19 '13

Please help me with this Java Question

The mathematician Augustus De Morgan was aged 43 in the year 1849AD. This is interesting because 43 squared is 1849, ie, in 1849 his age was the square root of the year. Given that no person has ever lived longer than 123 years (and assuming that no one ever will), write a Java application that will determine if it is possible that anyone who is alive today is, has ever been, or will ever be alive in a year that is the square of their age. If it is possible, your program should print out the years in which it happens and the ages that the people concerned will have in those years.

Here is what I have worked on till now

public class SquareAge {

public static final int START_YEAR=2013;
public static final int YEAR_MAX= 2136;
public static final int YEAR_MIN=1890;
public static final int MAXIMUM_AGE=123;


		

	public static void main(String[] args) {
		
	
	int age;
			for (age=0; age<=MAXIMUM_AGE; age++);
		    	
				{
					int agesquare=age*age;
				
				
				
				if (agesquare>=YEAR_MIN && agesquare<=YEAR_MAX &&  age>=agesquare-START_YEAR) 
				{
					System.out.print("the age is " + age + " the year is " + agesquare);
					
				}
				
				else
				{
					System.out.print("none");
				}
				
				
				}
	}
}
0 Upvotes

6 comments sorted by

View all comments

4

u/TheHorribleTruth Kind of meh Oct 19 '13

Please read the posting instructions. You're just posting your task description, solving which is not the point of this subreddit.

  • you don't ask any specific question. what exactly do you need help with?

  • you don't show what code you already have

0

u/ranar1 Oct 19 '13

Thanks. I have just added what I have worked on till now.

2

u/TheHorribleTruth Kind of meh Oct 19 '13

you're still not asking a question, so we don't know what you actually what help with.

again, read the posting instructions - all of them - and follow them.