Question: Need to fill this out and i'm stuck! import java.io.*; import java.util.*; /** * Primes is a program that will compute prime numbers using the

Need to fill this out and i'm stuck!

import java.io.*;

import java.util.*;

/**

* Primes is a program that will compute prime numbers using the sieve of Eratosthenes.

*

* @author Charles Hoot

* @version 4.0

*/

public class Primes

{

public static void main(String args[])

{

int max;

System.out.println("Please enter the maximum value to test for primality");

max = getInt(" It should be an integer value greater than or equal to 2.");

// COMPLETE THE MAIN

}

/**

* getComposites - Remove the composite values from possibles list and

* put them in the composites list.

*

* @param candidates A list of integers holding the possible values.

* @param composites A list of integers holding the composite values.

* @param prime An Integer that is prime.

*/

public static void getComposites(ListInterface candidates, ListInterface composites, Integer prime)

{

// COMPLETE THIS METHOD

}

/**

* Get an integer value.

*

* @return An integer.

*/

private static int getInt(String rangePrompt)

{

Scanner input;

int result = 10; //Default value is 10

try

{

input = new Scanner(System.in);

System.out.println(rangePrompt);

result = input.nextInt();

}

catch(NumberFormatException e)

{

System.out.println("Could not convert input to an integer");

System.out.println(e.getMessage());

System.out.println("Will use 10 as the default value");

}

catch(Exception e)

{

System.out.println("There was an error with System.in");

System.out.println(e.getMessage());

System.out.println("Will use 10 as the default value");

}

return result;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!