Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 lines that are divisible by the previous line, in reverse order. For example, if the input is 4 2 not divisible by the previous line 8 divisible by 2, so we output 8 8 divisible by 8, so we output 8 The output is therefore 8 8

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.util.List;

import java.util.ArrayList;

import java.util.Deque;

import java.util.ArrayDeque;

import java.util.Iterator;

public class CSE316 {

/**

* Read lines one at a time from r. Outputs to w according to the

* lab specifications.

* Assumes every line is an integer; otherwise it throws a NumberFormatException.

* @param r the reader to read from

* @param w the writer to write to

* @throws IOException, NumberFormatException

*/

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

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

w.println(-1);

}

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

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

Students also viewed these Databases questions

Question

How will the members be held accountable?

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago