// Your Name
// Date

// Prime.java (Skeleton of the program. Must be modified to compile!!!)
// // This program ask for a low and high integer, then count from low to high // listing all the factors of each number or "PRIME". import java.util.Scanner; public class Prime { // Variables, data // low - starting low number to print prime factors // high - ending high number to print prime factors private int low, high; // Constructor - initializes class variables public Prime ( ) { low = 2; high = 15; } // main method public static void main ( String [] args ) { Prime runprime = new Prime ( ); runprime.GetRange(); // get low and high numbers from user runprime.PrintListPrimes(); // print list of factors or "PRIME" } // GetRange() inputs low and high integers from user public void GetRange ( ) { Scanner key = new Scanner ( System.in ); // Insert your code HERE } // PrintListPrimes() goes through each number (counter) from low to high and // calls CheckIfPrime. public void PrintListPrimes ( ) { // Insert your code HERE } // CheckIfPrime() counts from 2 on up checking to see if it divides evenly into "counter". // If it find a number less than "counter" which divides evenly, then it calls // PrintAllFactors. If not, then print "PRIME". public void CheckIfPrime ( int counter ) { int i = 2; // Insert your code HERE } // PrintAllFactors() goes through each factor starting with 2 on up // testing if it divides evenly. If it does, then print the factor. public void PrintAllFactors ( int number, int i ) { // Insert your code HERE } }

Back to Lesson 7 Examples

Back to Java Main Page