Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
import java.Scanner; import java.ArrayList; import java.File; import java.PrintWriter; public class task1 { public static void main(String args) {...
This is an incomplete program. The goal of the program is to:
- Read a file that contains integers.
- Determine if each of those integers is a prime or not.
Complete that program, by defining acheck_primesfunction, that satisfies the following specs:
- Functioncheck_primestakes two arguments, calledin_file, out_file. Argumentin_filespecifies the name of the input file, that contains the integers to be processed. Argumentout_filespecifies the name of the output file, where the results will be saved.
- Ifin_filecannot be opened for reading, the function should print on the screen "Error in opening file for reading" and return.
- Ifout_filecannot be opened for writing, the function should print on the screen "Error in opening file for writing" and return.
- Otherwise, if both in_file and out_file can be opened: for each integer X stored in in_file, the function writes to out_file a line stating either "X is prime" or "X is not prime".
IMPORTANT: You are NOT allowed to modify in any way the main function.