Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

6.3 Explain the importance of application forms.

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago