Question: Task 1 (15 pts.) The program task1.java given below is an incomplete program. The goal of the program is to: Read a file that contains



Task 1 (15 pts.) The program task1.java given below 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. 1. 2. Complete that program, by defining a check_primes function, that satisfies the following specs: Function check_primes takes two arguments, called in file, out file. Argument in file specifies the name of the input file, that contains the integers to be processed. Argument out_file specifies the name of the output file, where the results will be saved. If in_file opening file for reading" and return. cannot be opened for reading, the function should print on the screen "Error in . If out_file cannot 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" For example, for input file in1.txt (format given below), the program should produce an output file that looks EXACTLY like out1.txt (format given below) IMPORTANT: You are NOT allowed to modify in any way the main function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
