Question: public static void execute(BufferedReader r, PrintWriter w) throws IOException, NumberFormatException { // TODO(student): Your code goes here. } in java please!!! Part 2. [10 marks]

 public static void execute(BufferedReader r, PrintWriter w) throws IOException, NumberFormatException {

public static void execute(BufferedReader r, PrintWriter w) throws IOException, NumberFormatException {

// TODO(student): Your code goes here.

}

in java please!!!

Part 2. [10 marks] Given a file where each line is a single (32-bit) positive integer, read in the lines of the file one at a time; output the sum modulo 240223 of every vth line starting from the last line, until you've summed ceil( n/2) lines, where n is the number of lines in the file, and v>0 is the value of the last line. If the file is empty, output 0 . For example, if the input is 30 40 this is the is the second line we sum because it's at index 54=1. 20 this is the third line we sum because it's at index (5-8) wrapping around. 10 4 we start at the line at index 5. This defines v=4 and n=6. then the output is 49 , because (4+40+5)%240223=49; since n=6 we will sum 3 lines, starting with the last, then 4th from the last, then 4th behind that, wrapping around. For more examples, see the tests in the tests/ directory that have the form lab1-p2-X-in.txt for the input, and the matching lab1-p2-X-out.txt for the expected output. Note that here you are selecting ceil( n/2) lines, defined by every vth line starting from the end

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!