Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the code to the assignment in JAVA? Please provide the code for problem

ID: 3808609 • Letter: W

Question

What is the code to the assignment in JAVA? Please provide the code for problem 22.8 and 22.10. 22.8 : The problem states to find all prime numbers up to 10,000,000,000.

Requirements:

-The code should store the prime numbers in a binary data file named PrimeNumbers.dat. When a new prime number is found it should be appended to the file.

-To find whether a new number is prime, the program should load the prime numbers from the file to an array of the long type of size 10,000. If no number in the array is a divisor for the new number, continue to read the next 10000 prime numbers from the data file, until a divisor is found or all the numbers in the file are read. If no divisor is found the new number is prime.

- Since this program takes a long time to finish, you should run it as a batch job from a UNIX machine. If the machine is shut down and rebooted, your program should resume by using the prime numbers stored in a binary data file rather than start over from scratch.

In 22.8 the program is supposed to find the number of prime numbers that are less than or equal to 10, 100, 1,000, 10,000, 100,000, 1,000,000, 10,000,000, 1000,000,000, 1,000,000,000, and 10,000,000,000. And this program should read the data from PrimeNumbers.dat.

Explanation / Answer

mport java.util.*; public class PRIME1 { static int numCases; static int left, right; static boolean[] initSieve = new boolean[32000]; static boolean[] answer; public static void main(String[] args) { Scanner sc = new Scanner(System.in); numCases = sc.nextInt(); initSieve[0] = true; initSieve[1] = true; Sieve(); for (int j = 0; j
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote