import java.io.*; import java.util.Scanner; public class SampleFinal5 { public static void main(String[] arg) throws IOException { // input file Scanner infile = new Scanner(new File("input5.txt")); // output file PrintWriter outfile = new PrintWriter("output5.txt"); double quot; int count=0; double closest=Double.MAX_VALUE; // if you don't use MAX_VALUE, you have to use structured read loop while (infile.hasNext()) { int num1 = infile.nextInt(); int num2 = infile.nextInt(); if (num1+num2 > 0) quot = (double)num1/num2; else quot = (double)num2/num1; outfile.println(num1 + " " + num2 + " " + quot); // part c -- closest to zero if (Math.abs(quot) < Math.abs(closest)) closest = quot; count++; } infile.close(); outfile.close(); System.out.println(count + " pairs processed."); System.out.println(closest + " is the quotient closest to zero."); } }