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

 Task 1 (15 pts.) The program task1.java given below is an

Task 1 (15 pts.) The program task1.java given below is an incomplete program. The goal of the program is to: 1. Read a file that contains integers. Determine if each of those integers is a prime or not. 2. Complete that program, by defining a check primes function, that satisfies the following specs: Function check prines 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 filespecifies the name of the output file, where the results will be saved. .If in file cannot be opened for reading, the function should print on the screen "Error in opening file for reading" and return. 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. Hint: the slides on functions contain a function called is prime that can be useful here task1.java import java.util.Seanner import java.util.ArrayList; inport java.io.Pile import java.io.PrintWriteri public class taskl publie statie vold main(Stringt 1 arga check prines(in1.txt o System, out . printf("Exiting. ..-); outl.txt

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!