Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions