import java.io.PrintWriter; import java.util.Scanner; public class hw { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int birth; int current; //user what year they were born System.out.println("What year were you born"); birth = sc.nextInt(); //ask user what the current year is System.out.println("What is the current year?"); current = sc.nextInt(); int age = current - birth; boolean prime; boolean perfect; prime = isPrime(age); perfect = isPerfect(age); if(prime) { System.out.println("your age is prime"); } if(perfect) { System.out.println("your age is perfect");} // done with main } // start a new function, isPerfect, which tests if the number is ap perfect power public static boolean isPerfect(int number) { for(int i = 1; i <= 10; i++) { if((i*i) == number) { return true; } else if((i*i*i) == number) { return true; } } return false; } public static boolean isPrime(int number) { for(int i = 1; i <= number; i--) { if(number % i == 0) { return false; } else if(i == 1) { return true; } } return false; } }