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. w.println(-1); } in java Part 1. [10 marks]

image text in transcribed

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

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

w.println(-1);

}

in java

Part 1. [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 each line (other than the first) that is a multiple of its previous line. For example, if the input is 398240224firstlinehasnopreviousline;wedontincludeitever9isamultipleof3,soweaddittooursum8isnotamultipleof9,sowedontincludeit240224isamultipleof8,soweaddittooursum Then the output is 10 , since (9+240224)%240223=10. Be careful of integer overflow: if x+y> Integer.MAX_VALUE then x+y will (incorrectly) be a negative number. Use the mathematical properties of mod highlighted above to avoid such overflow (note that (9%240223+240224%240223)%240223=(9+1)%240223=10%240223=10). For more examples, see the tests in the tests/ directory that have the form lab1-p1-X-in.txt for the input, and the matching lab1-p1-X-out.txt for the expected output

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

=+Do you want to work from home?

Answered: 1 week ago

Question

=+ What skills and competencies will enable someone

Answered: 1 week ago

Question

=+to live and work wherever he or she wants?

Answered: 1 week ago