Check11B - Scanner fileInput = new Scanner(new...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; import java.io.*; i public class Check11B { public static void main(String[] args) { PrintStream out = System.out; Scanner in = new Scanner(System.in); out.print("Entry . .. "); String buffer = in.nextLine(); try { String buffer2 = buffer.split("/")[1]; int month; try { month = Integer.parseInt(buffer.split("/")[0]); } catch (Exception e) { throw new Exception("Non-numeric Entry"); } if (month < 1 || month > 12) { throw new ArrayIndexOutOfBoundsException(""); } Calendar calender = Calendar.getInstance(); calender.set(Calendar.MONTH, month - 1); String fileName = calender.getTime().toString().split(" ")[1] + ".txt";
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Scanner fileInput = new Scanner(new File(fileName)); out.println(&quot;The Filename is: &quot; + fileName); buffer = fileInput.nextLine(); if (buffer.equals(&quot;&quot;) || buffer.equals(&quot; &quot;)) { throw new Exception(&quot;File Empty&quot;); } try { out.printf(&quot;The double # is: %.2f%n&quot;, Double.valueOf(buffer)); } catch (Exception e) { throw new Exception(&quot;Non-numeric record&quot;); } } catch (ArrayIndexOutOfBoundsException e) { out.println(&quot;Invalid Input&quot;); } catch (FileNotFoundException e) { out.println(&quot;File not found&quot;); } catch (Exception e) { out.println(e.getMessage()); } } }...
View Full Document

Page1 / 2

Check11B - Scanner fileInput = new Scanner(new...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online