here's my code thus far:

import java.util.*; import java.io.*; public class PrimeFactors { public static boolean isPrime(int n) { if (n<0) { n = -n; } for (int i = 2; i <= Math.sqrt(n); i++) { boolean divisible = (n % i == 0); if (divisible) { return false; } } return true; } public static void factorize(int number) { System.out.print(number + " = "); int count; for (int i = 2; i < number; i++) { count = 0; while (number % i == 0) { count++; number /= i; } if (number % i == 0) { String factors = "" + i + "^" +count; System.out.print(factors); } } } public static void main(String[] arg) throws IOException { // make a scanner Scanner scanner = new Scanner(System.in); // find out the input source System.out.print("What is the input filename:"); String inputFileName = scanner.nextLine(); inputFileName = inputFileName.trim(); // if not from file then allow for user input if (inputFileName.isEmpty()) { System.out.print("\nReading input from keyboard.\nPlease provide numbers: "); while (scanner.hasNextInt()) { int number = scanner.nextInt(); // test to see if number is prime boolean primeOrNotPrime = isPrime(number); // if prime, then factorize number if ( primeOrNotPrime != true) { factorize(number); } // if not prime, then say is equal to itself multiplied by one else { System.out.print(number + " = " + number + " * 1"); } } }else { // try // { Scanner fileIn = new Scanner(new FileReader(inputFileName)); while (fileIn.hasNextInt()) { int number = scanner.nextInt(); // test to see if number is prime boolean primeOrNotPrime = isPrime(number); // if prime, then factorize number if ( primeOrNotPrime != true) { factorize(number); } // if not prime, then say is equal to itself multiplied by one else { System.out.print(number + " = " + number + " * 1"); } } } } }