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

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

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